コード例 #1
0
        private MultiMoves GetBreakBonusMoves(BonusIDType opponentBonus, MultiMoves presentMoves)
        {
            var bonusTerritories                     = GameState.Map.Bonuses[opponentBonus].Territories;
            var distances                            = MapInformer.GetDistancesFromTerritories(bonusTerritories);
            var ownedBorderTerritories               = MapInformer.GetOwnedBorderTerritories(presentMoves.GetTerritoryStandingsAfterAllMoves(), GameState.MyPlayerId);
            int minDistance                          = ownedBorderTerritories.Min(o => distances[o.ID]);
            var bestStartTerritory                   = ownedBorderTerritories.Where(o => distances[o.ID] == minDistance).First();
            int currentDistance                      = minDistance;
            var currentTerritoryInAttackPath         = bestStartTerritory.ID;
            List <TerritoryIDType> territoriesToTake = new List <TerritoryIDType>();

            while (currentDistance != 0)
            {
                var neighbors = MapInformer.GetNeighborTerritories(currentTerritoryInAttackPath);
                var possibleAttackNeighbors = neighbors.Where(n => distances[n] == currentDistance - 1).ToList();
                var bestNeighborToAttack    = GetBestNeighborToAttack(possibleAttackNeighbors);
                territoriesToTake.Add(bestNeighborToAttack);
                currentTerritoryInAttackPath = bestNeighborToAttack;
                currentDistance--;
            }
            TakeTerritoriesTask takeTerritoriesTask = new TakeTerritoriesTask(REASON);
            MultiMoves          resultMoves         = takeTerritoriesTask.CalculateTakeTerritoriesMoves(territoriesToTake, presentMoves);

            return(resultMoves);
        }
コード例 #2
0
        // Calculates for each bonus on the map the steps necessary to take it
        // Currently only neighboring bonuses are seen as applicable
        public List <MultiMoves> CalculateTakeBonusMultiTask(MultiMoves presentMoves)
        {
            List <MultiMoves> resultMoves = new List <MultiMoves>();
            Dictionary <BonusIDType, BonusDetails> applicableBonuses = GetApplicableBonuses(presentMoves);

            foreach (var bonus in applicableBonuses.Values)
            {
                var territoriesToTake = GetMissingBonusTerritories(bonus, presentMoves);
                TakeTerritoriesTask takeTerritoriesTask = new TakeTerritoriesTask(REASON);
                MultiMoves          calculatedMoves     = takeTerritoriesTask.CalculateTakeTerritoriesMoves(territoriesToTake, presentMoves);
                if (calculatedMoves != null)
                {
                    resultMoves.Add(calculatedMoves);
                }
            }

            return(resultMoves);
        }