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 => { }); }
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); } }