private void InitLastMove() { lastMove = new Dictionary<string, int>(7); FirstMoveAdviser firstMoveAdviser = new FirstMoveAdviser(Context); DefendAdviser defendAdviser = new DefendAdviser(Context); InvadeAdviser invadeAdviser = new InvadeAdviser(Context); AttackAdviser attackAdviser = new AttackAdviser(Context); SupplyAdviser supplyAdviser = new SupplyAdviser(Context); StealAdviser stealAdviser = new StealAdviser(Context); AntiCrisisAdviser antiCrisiAdviser = new AntiCrisisAdviser(Context); lastMove.Add(firstMoveAdviser.GetAdviserName(), 0); lastMove.Add(defendAdviser.GetAdviserName(), 0); lastMove.Add(invadeAdviser.GetAdviserName(), 0); lastMove.Add(attackAdviser.GetAdviserName(), 0); lastMove.Add(supplyAdviser.GetAdviserName(), 0); lastMove.Add(stealAdviser.GetAdviserName(), 0); lastMove.Add(antiCrisiAdviser.GetAdviserName(), 0); }
public void DoTurn() { try { if (turn == 1) { FirstMoveAdviser firstMoveAdviser = new FirstMoveAdviser(Context); FirstMoveAdviser.CheckTime checkTime = CheckTime; firstMoveAdviser.CheckTimeFunc = checkTime; RunAdviser(firstMoveAdviser); return; } if (Context.MyPlanets().Count == 0) return; DefendAdviser defendAdviser = new DefendAdviser(Context); InvadeAdviser invadeAdviser = new InvadeAdviser(Context); AttackAdviser attackAdviser = new AttackAdviser(Context); StealAdviser stealAdviser = new StealAdviser(Context); //AntiCrisisAdviser antiCrisisAdviser = new AntiCrisisAdviser(Context); RunAdviser(defendAdviser); if (!CheckTime()) return; Config.AttackSendMoreThanEnemyCanDefend = true; Config.UseSectorsForFront = true; if (Context.MyFutureProduction < Context.EnemyFutureProduction || ((Context.MyFutureProduction == Context.EnemyFutureProduction) && (Context.MyTotalShipCount < Context.EnemyTotalShipCount))) { if (turn - lastMove[attackAdviser.GetAdviserName()] > Config.IdleTurns && turn - lastMove[invadeAdviser.GetAdviserName()] > Config.IdleTurns && turn - lastMove[stealAdviser.GetAdviserName()] > Config.IdleTurns) { //Config.UseSectorsForFront = false; //Config.AttackSendMoreThanEnemyCanDefend = false; #if LOG Logger.Log("UseSectorsForFront = false"); #endif //antiCrisisAdviser.Attack = Context.MyTotalShipCount < Context.EnemyTotalShipCount; //RunAdviser(antiCrisisAdviser); //if (!CheckTime()) return; } } RunAdviser(stealAdviser); if (!CheckTime()) return; Config.InvadeSendMoreThanEnemyCanDefend = true;//(Context.MyProduction > Context.EnemyProduction*Config.DoInvadeKoef); RunAdviser(invadeAdviser); if (!CheckTime()) return; RunAdviser(attackAdviser); if (!CheckTime()) return; } finally { try { if (turn == 1) { MakeMoves(setList); setList.Clear(); } else { SelectAndMakeMoves(); if (CheckTime()) { //try { SupplyAdviser supplyAdviser = new SupplyAdviser(Context); RunAdviser(supplyAdviser); if (CheckTime()) { MakeMoves(setList); setList.Clear(); } } //catch { //Logger.Log("exception: " + e.Message); } } } } finally { Context.FinishTurn(); } } }