示例#1
0
        public BonusAnalyzer(CowzowBot bot)
        {
            this.Bot = bot;
            BonusBuckets = new Dictionary<BonusIDType, int>();
            BonusCosts = new Dictionary<BonusIDType, int>();
            TroopEstimate = 5;
            foreach (var bonus in Bot.BotMap.Bonuses.Values)
            {
                BonusBuckets[bonus.ID] = 0;
                var cost = 0;
                foreach (var r in bonus.Territories)
                {
                    if (Bot.DistributionStanding != null)
                        cost += Bot.DistributionStanding.Territories[r.ID].NumArmies.NumArmies;
                    else if (!Bot.LatestStanding.Territories[r.ID].NumArmies.Fogged)
                        cost += Bot.LatestStanding.Territories[r.ID].NumArmies.NumArmies;
                    else
                        cost += Bot.Settings.InitialNonDistributionArmies;
                }

                BonusCosts[bonus.ID] = cost;
            }

            //foreach (var r_1 in State.OpponentStartingTerritories)
            //    BonusBuckets[r_1.Bonus] += 2;
        }
示例#2
0
 public OrderManager(CowzowBot bot, IEnumerable <TerritoryIDType> myTerritories)
 {
     this.Bot = bot;
     Orders   = new Dictionary <TerritoryIDType, EdgeHashSet>();
     foreach (var r in myTerritories)
     {
         Orders[r] = new EdgeHashSet();
     }
 }
示例#3
0
        private Dictionary <TerritoryIDType, int> ConstructCaptureCosts(CowzowBot Bot)
        {
            var captureCosts = new Dictionary <TerritoryIDType, int>();

            foreach (var r in BotMap.VisibleTerritories)
            {
                if (r.OwnerPlayerID == TerritoryStanding.NeutralPlayerID)
                {
                    var est = ArmiesNeededToCapture(r.Armies);
                    captureCosts[r.ID] = est;
                }
                else
                {
                    if (IsOpponent(r.OwnerPlayerID))
                    {
                        if (OpponentOrders.OfType <GameOrderDeploy>().None(o => o.DeployOn == r.ID) && r.Bonuses.Any(Analyzer.MightBeOwned))
                        {
                            var maxThreat = 0;
                            foreach (var n in r.Neighbors)
                            {
                                if (n.IsVisible && n.OwnerPlayerID == Me.ID)
                                {
                                    var threat = OpponentVision[n.ID];
                                    if (threat > maxThreat)
                                    {
                                        maxThreat = threat;
                                    }
                                }
                            }
                            var visibleCount = r.Bonuses.SelectMany(o => o.Territories).Where(o => o.IsVisible).Select(o => o.ID).Distinct().Count();

                            var est = Math.Max(maxThreat - 1, ArmiesNeededToCapture(r.Armies + 2));
                            if (visibleCount == 1 && r.Bonuses.Any(b => b.ArmiesReward >= 3))                   //TODO: Magic numbers
                            {
                                var defendEst = (int)(0.75 * Math.Min(Analyzer.TroopEstimate, MyIncome.Total)); //TODO: Settings
                                est = Math.Max(est, ArmiesNeededToCapture(defendEst));
                            }
                            // est = Math.max(est, armiesNeededToCapture(r.getArmies()));
                            // est = Math.max(est, 5);
                            captureCosts[r.ID] = est;
                        }
                        else
                        {
                            if (OpponentOrders.OfType <GameOrderDeploy>().None(o => o.DeployOn == r.ID) && !r.Bonuses.Any(Analyzer.MightBeOwned))
                            {
                                var count = 0;
                                foreach (var tmp in BotMap.VisibleTerritories)
                                {
                                    if (IsOpponent(tmp.OwnerPlayerID))
                                    {
                                        count++;
                                    }
                                }
                                var est = ArmiesNeededToCapture(r.Armies + Math.Min(2, Analyzer.GetEffectiveTroops() / Math.Max(count, 1)));
                                captureCosts[r.ID] = est;
                            }
                            else
                            {
                                var oppDeployed = OpponentOrders.OfType <GameOrderDeploy>().Single(o => o.DeployOn == r.ID).NumArmies;
                                var guess       = r.Armies;
                                guess += (int)((oppDeployed + 0.5) / 2);

                                foreach (var move in Bot.PreviousTurn.OfType <GameOrderAttackTransfer>().Where(o => o.PlayerID == Bot.Me.ID))
                                {
                                    if (move.To == r.ID)
                                    {
                                        guess += oppDeployed / 2;
                                        break;
                                    }
                                }

                                if (r.Bonuses.Any(Analyzer.MightBeOwned))
                                {
                                    guess += 1;
                                }
                                var est = ArmiesNeededToCapture(guess);
                                captureCosts[r.ID] = est;
                            }
                        }
                    }
                    else
                    {
                        var est = (int)Math.Max(1.7 * r.Armies, r.GetStrongestNearestEnemy() + 2); //TODO: Settings
                        est = Math.Max(est, r.Armies + Analyzer.TroopEstimate / 2);
                        captureCosts[r.ID] = est;
                    }
                }
            }
            return(captureCosts);
        }