using System.Collections;
using System.Collections.Generic;
public static int attackerInfantry = 0;
public static int attackerArtillery = 0;
public static int attackerTanks = 0;
public static int attackerPlanes = 0;
public static int attackerBombers = 0;
public static int defenderInfantry = 0;
public static int defenderArtillery = 0;
public static int defenderTanks = 0;
public static int defenderPlanes = 0;
public static int defenderBombers = 0;
public static int attackerInfantryToHit = 1;
public static int attackerBoostedInfantyToHit = 2;
public static int attackerArtilleryToHit = 2;
public static int attackerTankToHit = 3;
public static int attackerPlaceToHit = 3;
public static int attackerBomberToHit = 4;
public static int defenderInfantyToHit = 2;
public static int defenderArtilleryToHit = 2;
public static int defenderTankToHit = 3;
public static int defenderPlaceToHit = 4;
public static int defenderBomberToHit = 1;
public static int round = 1;
public static string winner = null;
public static void Main()
GetValsFromString(100, 100, 0, 0, 0, "x", 0, 0, 140, 0, 0);
Console.WriteLine("Round " + round);
Console.WriteLine("Remaining attackers = " + attackerInfantry + " infantry, " + attackerArtillery + " artillery, " + attackerTanks + " tanks, " + attackerPlanes + " planes, " + attackerBombers + " bombers");
Console.WriteLine("Remaining defenders = " + defenderInfantry + " infantry, " + defenderArtillery + " artillery, " + defenderTanks + " tanks, " + defenderPlanes + " planes, " + defenderBombers + " bombers");
public static bool SimulateRound()
int attackerBoostedInfantry = 0;
int attackerInfantryTemp = 0;
if (attackerArtillery > 0)
if (attackerArtillery >= attackerInfantry)
attackerBoostedInfantry = attackerInfantry;
attackerInfantryTemp = 0;
attackerBoostedInfantry = attackerArtillery;
attackerInfantry = attackerInfantry - attackerArtillery;
int effectiveArtillery = attackerBoostedInfantry + attackerArtillery;
numHitsAttacker = GetHits("attacker", attackerInfantryTemp, effectiveArtillery, attackerTanks, attackerPlanes, attackerBombers);
numHitsDefender = GetHits("defender", defenderInfantry, defenderArtillery, defenderTanks, defenderPlanes, defenderBombers);
Console.WriteLine("attacker gets " + numHitsAttacker + "hits");
Console.WriteLine("defender gets " + numHitsDefender + "hits");
TakeHits(numHitsAttacker, numHitsDefender);
if ((attackerInfantry < 1) && (attackerArtillery < 1) && (attackerTanks < 1) && (attackerPlanes < 1) && (attackerBombers < 1))
else if ((defenderInfantry < 1) && (defenderArtillery < 1) && (defenderTanks < 1) && (defenderPlanes < 1) && (defenderBombers < 1))
if (winner == "defender") winner = "TIE";
else winner = "attacker";
private static void TakeHits(int defendersHits, int attackersHits)
int remainingAttackerHits = attackersHits;
int remainingDefenderHits = defendersHits;
if (remainingDefenderHits >= defenderInfantry)
remainingDefenderHits -= defenderInfantry;
defenderInfantry -= remainingDefenderHits;
remainingDefenderHits = 0;
if (remainingDefenderHits >= defenderArtillery)
remainingDefenderHits -= defenderArtillery;
defenderArtillery -= remainingDefenderHits;
remainingDefenderHits = 0;
if (remainingDefenderHits >= defenderTanks)
remainingDefenderHits -= defenderTanks;
defenderTanks -= remainingDefenderHits;
remainingDefenderHits = 0;
if (remainingDefenderHits >= defenderPlanes)
remainingDefenderHits -= defenderPlanes;
defenderPlanes -= remainingDefenderHits;
remainingDefenderHits = 0;
if (remainingDefenderHits >= defenderBombers)
remainingDefenderHits -= defenderBombers;
defenderBombers -= remainingDefenderHits;
remainingDefenderHits = 0;
if (remainingAttackerHits >= attackerBombers)
remainingAttackerHits -= attackerBombers;
attackerBombers -= remainingAttackerHits;
remainingAttackerHits = 0;
if (remainingAttackerHits >= attackerInfantry)
remainingAttackerHits -= attackerInfantry;
attackerInfantry -= remainingAttackerHits;
remainingAttackerHits = 0;
if (remainingAttackerHits >= attackerArtillery)
remainingAttackerHits -= attackerArtillery;
attackerArtillery -= remainingAttackerHits;
remainingAttackerHits = 0;
if (remainingAttackerHits >= attackerTanks)
remainingAttackerHits -= attackerTanks;
attackerTanks -= remainingAttackerHits;
remainingAttackerHits = 0;
if (remainingAttackerHits >= attackerPlanes)
remainingAttackerHits -= attackerPlanes;
attackerPlanes -= remainingAttackerHits;
remainingAttackerHits = 0;
private static int GetHits(string side, int inf, int art, int tanks, int planes, int bombers)
for (int i = 0; i < inf; i++)
if (GetRandomNumber(1, 6) <= infantryToHit) hits++;
for (int i = 0; i < art; i++)
if (GetRandomNumber(1,6) <= artilleryToHit) hits++;
for (int i = 0; i < tanks; i++)
if (GetRandomNumber(1, 6) <= tanksToHit) hits++;
for (int i = 0; i < planes; i++)
if (GetRandomNumber(1, 6) <= planesToHit) hits++;
for (int i = 0; i < bombers; i++)
if (GetRandomNumber(1,6) <= bombersToHit) hits++;
private static void GetValsFromString (int ai, int aa, int at, int ap, int ab, string dummy, int di, int da, int dt, int dp, int db)
private static readonly Random getrandom = new Random();
public static int GetRandomNumber(int min, int max)
return getrandom.Next(min, max);