public int Start() { bool fightTied = false; while (ImmuneSystem.Any(g => !g.Removed) && Infection.Any(g => !g.Removed) && !fightTied) { var unitCountBeforeRound = GroupsInTargetSelectionOrder.Sum(g => g.Units); var alreadySelected = new HashSet <int>(); foreach (var group in GroupsInTargetSelectionOrder) { var target = group.SelectTarget(alreadySelected); if (target != null) { alreadySelected.Add(target.Id); } } foreach (var group in GroupsInAttackingOrder) { group.AttackTarget(); } fightTied = unitCountBeforeRound == GroupsInTargetSelectionOrder.Sum(g => g.Units); } var immuneSystemPoints = ImmuneSystem.Where(g => g.Units >= 0).Sum(g => g.Units); var infectionPoints = Infection.Where(g => g.Units >= 0).Sum(g => g.Units); return(Math.Max(immuneSystemPoints, infectionPoints)); }