public void Solve() { Factory factory = mission.factory; mission.finalEnlistedTroops = new List <Troop>(); if (Game.bomb <= 0) { mission.successRating = MissionSuccessRating.Impossible; return; } foreach (var pair in factory.links.OrderBy(p => p.Value)) { Factory neighbour = pair.Key; int distance = pair.Value; int missionEndTime = Game.gameTime + distance + 1; FactoryState lastState = FactoryState.GetFactoryState(factory, missionEndTime); if (lastState.team == Team.Enemy && neighbour.isAlly && !Bomb.bombs.Values.Any(b => b.isAlly && b.end == mission.factory)) //no bombs going there { int finalArmyCount = lastState.count + (distance + 1) * lastState.production; Bomb bomb = new Bomb { isAlly = true, isEnemy = false, team = Team.Ally, start = neighbour, end = mission.factory, turns = distance + 1, endTime = missionEndTime, }; /*int inTransitEnemyCount = 0; * foreach (var troop in Troop.enemy.Where(t=>t.end == mission.factory).OrderBy(t=>t.endTime)) * { * if (distance == troop.turns) * { * inTransitEnemyCount += troop.count; * } * }*/ if (lastState.production >= 2)//Factory.globalStats.enemyTotalProduction / 2 //|| lastState.count >= Factory.globalStats.totalEnemyCount / 2) { bomb.count = lastState.count; mission.finalEnlistedTroops.Add(bomb); mission.successRating = MissionSuccessRating.Guaranteed; break; } } } }
public void Solve() { Factory factory = mission.factory; foreach (var pair in factory.links.OrderBy(p => p.Value)) { Factory neighbour = pair.Key; int distance = pair.Value; int missionEndTime = Game.gameTime + distance + 1; FactoryState lastState = FactoryState.GetFactoryState(factory, missionEndTime); if (lastState.team == Team.Enemy && neighbour.isAlly && factory.production == 3 && !Bomb.bombs.Values.Any(b => b.isAlly && b.end == mission.factory)) //no bombs going there { int finalArmyCount = lastState.count + (distance + 1) * lastState.production; //Console.Error.WriteLine("Bomb" + lastState.id + (closestTroop.end == factory)); if (finalArmyCount >= Factory.globalStats.totalEnemyCount / 2 || lastState.production >= Factory.globalStats.enemyTotalProduction / 2) { Bomb bomb = new Bomb { isAlly = true, isEnemy = false, team = Team.Ally, start = neighbour, end = mission.factory, turns = distance + 1, endTime = missionEndTime, }; mission.finalEnlistedTroops = new List <Troop>(); mission.finalEnlistedTroops.Add(bomb); mission.successRating = MissionSuccessRating.Guaranteed; break; } } } }