public static void RunQuickMatch() { var game = new SabberStoneState(new SabberStoneCore.Model.Game(new GameConfig { StartPlayer = 1, Player1Name = Constants.SABBERSTONE_GAMECONFIG_PLAYER1_NAME, Player1HeroClass = CardClass.HUNTER, Player1Deck = Decks.GetRandomTournamentDeck(), Player2Name = Constants.SABBERSTONE_GAMECONFIG_PLAYER2_NAME, Player2HeroClass = CardClass.HUNTER, Player2Deck = Decks.GetRandomTournamentDeck(), FillDecks = false, Shuffle = true, SkipMulligan = false, History = false })); // Create two bots to play var bot1 = BotFactory.CreateSabberStoneBot(BotSetupType.RandomBot, game.Player1); var bot2 = BotFactory.CreateSabberStoneBot(BotSetupType.RandomBot, game.Player2); game.Game.StartGame(); game.Game.Process(MulliganStrategySabberStone.DefaultMulligan(game.Game.Player1)); game.Game.Process(MulliganStrategySabberStone.DefaultMulligan(game.Game.Player2)); game.Game.MainReady(); while (game.Game.State != State.COMPLETE) { Console.WriteLine(""); Console.WriteLine($"TURN {(game.Game.Turn + 1) / 2} - {game.Game.CurrentPlayer.Name}"); Console.WriteLine($"Hero[P1] {game.Player1.Hero} HP: {game.Player1.Hero.Health} / Hero[P2] {game.Player2.Hero} HP: {game.Player2.Hero.Health}"); Console.WriteLine($"- {game.Game.CurrentPlayer.Name} Action ----------------------------"); // Ask the bot to act. var action = game.Game.CurrentPlayer.Id == game.Player1.Id ? bot1.Act(game) : bot2.Act(game); // Check if the action is valid if (action == null || !action.IsComplete()) { continue; } // Process the tasks in the action foreach (var item in action.Tasks) { // Process the task Console.WriteLine(item.Task.FullPrint()); game.Game.Process(item.Task); } } Console.WriteLine($"Game: {game.Game.State}, Player1: {game.Player1.PlayState} / Player2: {game.Player2.PlayState}"); }
/// <summary> /// Constructs a new instance of a TournamentMatch with a specific GameConfig between two bots. /// Note: the order of the bots does not reflect the playing order in the match's games. (starting player is alternated) /// </summary> /// <param name="bot1Setup">The setup for the first bot.</param> /// <param name="bot2Setup">The setup for the second bot.</param> /// <param name="numberOfGames">The amount of games that should be played in this match.</param> /// <param name="budgetType">The type of budget that this match will be limited on.</param> /// <param name="budgetLimit">The amount of budget that is available to the players, relative to the <see cref="BudgetType"/>.</param> /// <param name="printToConsole">[Optional] Whether or not to print game information to the Console.</param> public TournamentMatch(BotSetupType bot1Setup, BotSetupType bot2Setup, int numberOfGames, BudgetType budgetType, long budgetLimit, bool printToConsole = false) { Bots = new List <ISabberStoneBot> { BotFactory.CreateSabberStoneBot(bot1Setup), BotFactory.CreateSabberStoneBot(bot2Setup) }; NumberOfGames = numberOfGames; BudgetType = budgetType; BudgetLimit = (long)(budgetLimit * 1.02); // I'll allow a 2% margin on the budget limitation. MatchStatistics = new MatchStatistics($"{bot1Setup.ToString()}[{Constants.SABBERSTONE_GAMECONFIG_PLAYER1_NAME}]", $"{bot2Setup.ToString()}[{Constants.SABBERSTONE_GAMECONFIG_PLAYER2_NAME}]", numberOfGames, BudgetType, BudgetLimit); _printToConsole = printToConsole; }