Ejemplo n.º 1
0
        public static void PlayForTurn(string botName, GameIDType gameID, int playForTurn)
        {
            AILog.Log("Generating orders for game " + gameID + " turn " + playForTurn);
            var settings = HumanGameAPI.GetGameSettings(gameID);
            var game     = HumanGameAPI.GetGameInfo(gameID, playForTurn);

            EntryPoint.PlayGame(botName, game, MeID, settings.Item1, settings.Item2, picks => { }, orders => { });
        }
Ejemplo n.º 2
0
        public static void PlayLoop(string botName, GameIDType gameID, PlayerIDType playerID)
        {
            var settings = HumanGameAPI.GetGameSettings(gameID);

            int  turnNumber    = int.MinValue;
            bool checkedAccept = false;

            while (true)
            {
                var status = HumanGameAPI.GetGameStatus(gameID);
                if (status.Item2 == GameState.WaitingForPlayers)
                {
                    if (!checkedAccept)
                    {
                        var game = HumanGameAPI.GetGameInfo(gameID, null);
                        if (game.Players[playerID].State == GamePlayerState.Invited)
                        {
                            AILog.Log("Accepting invite...");
                            HumanGameAPI.AcceptGame(gameID);
                            AILog.Log("Accepted invite");
                        }

                        checkedAccept = true;
                    }
                }
                else if (status.Item2 == GameState.Finished)
                {
                    AILog.Log("Game finished");
                    break;
                }
                else if (status.Item1 > turnNumber)
                {
                    var game = HumanGameAPI.GetGameInfo(gameID, null);

                    if (!EntryPoint.PlayGame(botName, game, MeID, settings.Item1, settings.Item2, picks =>
                    {
                        HumanGameAPI.SendPicks(game.ID, picks);
                        AILog.Log("Sent picks");
                    }, orders =>
                    {
                        HumanGameAPI.SendOrders(game.ID, orders, game.NumberOfTurns + 1);
                        AILog.Log("Sent orders");
                    }))
                    {
                        AILog.Log("We're no longer alive");
                        break;
                    }
                    turnNumber = status.Item1;
                }

                Thread.Sleep(10000);
            }
        }
Ejemplo n.º 3
0
        public static void Create(string botName, string opponent, string gameName)
        {
            AILog.Log("Creating game...");
            var gameID = HumanGameAPI.CreateGame(new[] {
                PlayerInvite.Create("me", (TeamIDType)0, null),
                PlayerInvite.Create("*****@*****.**", (TeamIDType)0, null),
                PlayerInvite.Create(opponent, (TeamIDType)1, null)
            }, gameName, null, settings =>
            {
                settings["Fog"]          = "NoFog";    //turn off fog so we can see what the AI is doing
                settings["MaxCardsHold"] = 999;        //so AI doesn't have to discard
                //settings["OrderPriorityCard"] = "none";
                //settings["OrderDelayCard"] = "none";
                //settings["BlockadeCard"] = "none";
                //settings["NumberOfCardsToReceiveEachTurn"] = 1;
            });

            AILog.Log("Created game " + gameID);
            PlayLoop(botName, gameID, MeID);
        }