public MakeOrdersMain(BotMain bot) { this.Bot = bot; this.Orders = new OrdersManager(Bot); this.IncomeTracker = new PlayerIncomeTracker(Bot.EffectiveIncome, Bot.Map); this.UpdateEffectiveIncome(); }
/// <summary> /// Asserts that the orders built so far deploy all armies the AI is receiving /// </summary> //private void VerifyIncomeAccurate() //{ // var actualIncome = GamePlayerReference.IncomeFromStanding(Orders.OfType<GameOrderPlayCardReinforcement>().Select(o => ((ReinforcementCardInstance)Game.LatestTurnStanding_ReadOnly.FindCard(o.CardInstanceID)).Armies).SumInts(), Game.LatestTurnStanding_ReadOnly, false, false); // var ordersDeploy = Orders.OfType<GameOrderDeploy>().Select(o => o.NumArmies).SumInts(); // if (actualIncome.Total != ordersDeploy) // { // //Throw some details in the error for debugging // var sb = new StringBuilder(); // sb.AppendLine("Order incomes inaccurate. ActualIncome = " + actualIncome + ", OrdersDeploy=" + ordersDeploy + ", NumOrders=" + Orders.Count); // foreach (var order in Orders) // sb.AppendLine("Order: " + order.ToString()); // Assert.Fatal(false, sb.ToString()); // } //} private void BuildOrders() { IncomeTracker = new PlayerIncomeTracker(Income, this.Map); var weightedAttacks = WeightAttacks(); PlayCards(); //Commanders run away CommandersMovement(); //Ensure teammates coordinate on bonuses ResolveTeamBonuses(); //Expand into good opportunities Expand(IncomeTracker.RemainingUndeployed, -500); //Now defend/attack DefendAttack(IncomeTracker.RemainingUndeployed, weightedAttacks); //Now expand into anything remaining Expand(IncomeTracker.RemainingUndeployed, int.MinValue); //If there's still remaining income, deploy it randomly DeployRemaining(); //Move any unused landlocked armies towards a border MoveLandlockedUp(); //If any attack has spare armies on the source territory, make the attack use them UtilizeSpareArmies(); //Verify we've deployed all armies //VerifyIncomeAccurate(); Assert.Fatal(IncomeTracker.FullyDeployed, "Not fully deployed"); }