Ejemplo n.º 1
0
        private static void PlayGame(string botName, int numOpponents)
        {
            var players = new[] { PlayerInvite.Create(MeID, (TeamIDType)1, null) }.Concat(Enumerable.Range(0, numOpponents).Select(o => PlayerInvite.Create("*****@*****.**", (TeamIDType)2, null)));

            AILog.Log("Creating game...");
            var gameID = BotGameAPI.CreateGame(players, "AI Competition", null, gameSettings => gameSettings["MaxCardsHold"] = 999);

            AILog.Log("Created game " + gameID);

            var settings = BotGameAPI.GetGameSettings(gameID);

            try
            {
                while (true)
                {
                    var game = BotGameAPI.GetGameInfo(gameID, MeID);
                    if (game.State == GameState.Finished)
                    {
                        GameFinished(game);
                        break;
                    }

                    if (!EntryPoint.PlayGame(botName, game, MeID, settings.Item1, settings.Item2, picks => BotGameAPI.SendPicks(game.ID, MeID, picks), orders => BotGameAPI.SendOrders(game.ID, MeID, orders, game.NumberOfTurns + 1)))
                    {
                        GameFinished(game);
                        break;
                    }

                    Thread.Sleep(100);
                }
            }
            finally
            {
                ExportGame(gameID);
                BotGameAPI.DeleteGame(gameID);
            }
        }
Ejemplo n.º 2
0
 private static void GameFinished(GameIDType gameID)
 {
     ExportGame(gameID);
     BotGameAPI.DeleteGame(gameID);
 }