예제 #1
0
        private TerritoryIDType GetBestNeighborToAttack(List <TerritoryIDType> possibleTargets)
        {
            var bestTarget = GameState.CurrentTurn().LatestTurnStanding.Territories[possibleTargets.First()];

            foreach (TerritoryIDType territoryId in possibleTargets)
            {
                var testTarget = GameState.CurrentTurn().LatestTurnStanding.Territories[territoryId];
                if (bestTarget.IsNeutral && testTarget.OwnerPlayerID == GameState.OpponentPlayerId)
                {
                    testTarget = bestTarget;
                }
                else if (bestTarget.IsNeutral && testTarget.IsNeutral && testTarget.NumArmies.ArmiesOrZero < bestTarget.NumArmies.ArmiesOrZero)
                {
                    testTarget = bestTarget;
                }
                else if (bestTarget.OwnerPlayerID == GameState.OpponentPlayerId && testTarget.OwnerPlayerID == GameState.OpponentPlayerId)
                {
                    var testTargetBonus = MapInformer.GetBonus(testTarget.ID);
                    var bestTargetBonus = MapInformer.GetBonus(bestTarget.ID);
                    var opponentBonuses = MapInformer.GetOwnedBonuses(GameState.CurrentTurn().LatestTurnStanding.Territories, GameState.OpponentPlayerId);
                    if (opponentBonuses.Keys.Contains(testTargetBonus.ID) && !opponentBonuses.Keys.Contains(bestTargetBonus.ID))
                    {
                        testTarget = bestTarget;
                    }
                    else if (opponentBonuses.Keys.Contains(testTargetBonus.ID) && opponentBonuses.Keys.Contains(bestTargetBonus.ID) &&
                             opponentBonuses[testTargetBonus.ID].Amount > opponentBonuses[bestTargetBonus.ID].Amount)
                    {
                        testTarget = bestTarget;
                    }
                }
            }
            return(bestTarget.ID);
        }
예제 #2
0
        private List <TerritoryIDType> GetNonOwnedBonusTerritoriesToTake(MultiMoves multiMoves)
        {
            // Choose an arbitrary territory with a non owned neighbor
            TerritoryIDType nonOwnedTerritory = new TerritoryIDType();

            foreach (var territory in multiMoves.GetTerritoryStandingsAfterAllMoves().Values.Where(t => t.OwnerPlayerID == GameState.MyPlayerId))
            {
                var nonOwnedNeighbors = MapInformer.GetNonOwnedNeighborTerritories(territory.ID, multiMoves.GetTerritoryStandingsAfterAllMoves());
                if (nonOwnedNeighbors.Count > 0)
                {
                    nonOwnedTerritory = nonOwnedNeighbors.First().Key;
                    break;
                }
            }
            var bonus = MapInformer.GetBonus(nonOwnedTerritory);

            AILog.Log("Debug", "Attempting to take bonus: " + bonus.Name);
            var nonOwnedBonusTerritories = MapInformer.GetNonOwnedBonusTerritories(bonus, multiMoves.GetTerritoryStandingsAfterAllMoves());

            return(nonOwnedBonusTerritories);
        }