Example #1
0
        private static void InitBot()
        {
            Bot = BotFactory.Construct("Prod");

            Players = new Dictionary <PlayerIDType, GamePlayer>();
            Players.Add(MyPlayerID, new GamePlayer(MyPlayerID, GamePlayerState.Playing, PlayerInvite.NoTeam, 0, false, false, false));
            Players.Add(OpponentPlayerID, new GamePlayer(OpponentPlayerID, GamePlayerState.Playing, PlayerInvite.NoTeam, 0, false, false, false));


            var incomes = new Dictionary <PlayerIDType, PlayerIncome>();

            incomes.Add(MyPlayerID, new PlayerIncome(StartingArmies));
            incomes.Add(OpponentPlayerID, new PlayerIncome(5));

            var settings = new GameSettings(0.6, 0.7, true, 5, 2, 2, 0, (DistributionIDType)0, new Dictionary <BonusIDType, int>(), false, false, false, 2, RoundingModeEnum.StraightRound, 0.16, false, false, new Dictionary <CardIDType, object>(), false, GameFogLevel.Foggy, false);

            Bot.Init((GameIDType)0, MyPlayerID, Players, Map, DistributionStanding, settings, NumberOfTurns, incomes, PrevTurn, LatestTurnStanding, PreviousTurnStanding, new Dictionary <PlayerIDType, TeammateOrders>(), new List <CardInstance>(), 0, Stopwatch.StartNew(), new List <string>());
        }
Example #2
0
        public static bool PlayGame(string botName, GameObject game, PlayerIDType playerID, GameSettings settings, MapDetails map, Action <List <TerritoryIDType> > sendPicks, Action <List <GameOrder> > sendOrders)
        {
            if (game.State == GameState.WaitingForPlayers)
            {
                return(true);
            }

            if (!game.Players.ContainsKey(playerID))
            {
                return(false); //not in game
            }
            if (game.Players[playerID].State == GamePlayerState.Invited)
            {
                throw new NotImplementedException("TODO: Accept the invite");
            }
            if (game.Players[playerID].State != GamePlayerState.Playing)
            {
                return(false); //not alive anymore
            }
            var bot = BotFactory.Construct(botName);

            bot.Init(game.ID, playerID, game.Players, map, game.LatestInfo.DistributionStanding, settings, game.NumberOfTurns, game.LatestInfo.Income, game.LatestInfo.LatestTurn == null ? null : game.LatestInfo.LatestTurn.Orders, game.LatestInfo.LatestStanding, game.LatestInfo.PreviousTurnStanding, game.LatestInfo.TeammatesOrders, game.LatestInfo.Cards, game.LatestInfo.CardsMustUse, Stopwatch.StartNew(), new List <string>());

            AILog.Log("PlayGame", "State=" + game.State + ", numTurns=" + game.NumberOfTurns + ", income=" + game.LatestInfo.Income[playerID] + ", cardsMustUse=" + game.LatestInfo.CardsMustUse);

            if (game.State == GameState.DistributingTerritories)
            {
                sendPicks(_speeds.GetOrAdd(botName, _ => new Speeds()).Record(true, () => bot.GetPicks()));
            }
            else if (game.State == GameState.Playing)
            {
                sendOrders(_speeds.GetOrAdd(botName, _ => new Speeds()).Record(false, () => bot.GetOrders()));
            }

            return(true);
        }