예제 #1
0
        // Simulate real game to see how your bot will perform in real games.
        private static async Task SimulatGamesScore <T>(ISmartBot <T> smartBot, int gameCount = 50) where T : LabeledDataPoint
        {
            Console.WriteLine("Simulating game.");

            // TODO-Extra: Try using different combination bots (you can use random) to compares yours in different settings.
            var bots = new IBot[]
            {
                smartBot,
                smartBot,
                smartBot,
                smartBot,
            };

            var playerScores = new Dictionary <string, List <int> >()
            {
                { "p1", new List <int>() },
                { "p2", new List <int>() },
                { "p3", new List <int>() },
                { "p4", new List <int>() },
            };

            for (int i = 0; i < gameCount; i++)
            {
                var simulation = await BomberjamRunner.StartSimulation(bots, false);

                while (!simulation.IsFinished)
                {
                    await simulation.ExecuteNextTick();
                }

                foreach (var player in simulation.CurrentState.Players)
                {
                    playerScores[player.Key].Add(player.Value.score);
                }
            }

            var avgP1 = playerScores["p1"].Aggregate((x, y) => x + y) / gameCount;
            var avgP2 = playerScores["p2"].Aggregate((x, y) => x + y) / gameCount;
            var avgP3 = playerScores["p3"].Aggregate((x, y) => x + y) / gameCount;
            var avgP4 = playerScores["p4"].Aggregate((x, y) => x + y) / gameCount;

            Console.WriteLine($"Average scores p1: {avgP1}");
            Console.WriteLine($"Average scores p2: {avgP2}");
            Console.WriteLine($"Average scores p3: {avgP3}");
            Console.WriteLine($"Average scores p4: {avgP4}");
            Console.WriteLine($"Average average: {(avgP1 + avgP2 + avgP3 + avgP4) / 4}");
        }
예제 #2
0
        private static async Task SimulateExample()
        {
            var bots = new IBot[]
            {
                new RandomBot(),
                new RandomBot(),
                new RandomBot(),
                new RandomBot()
            };

            const bool saveGamelogFile = true;
            var        simulation      = await BomberjamRunner.StartSimulation(bots, saveGamelogFile);

            while (!simulation.IsFinished)
            {
                await simulation.ExecuteNextTick();
            }

            Console.WriteLine(simulation.CurrentState.Tiles);
        }
예제 #3
0
        private static async Task SimulateExample <T>(ISmartBot <T> smartBot) where T : LabeledDataPoint
        {
            await smartBot.Load(modelSavePath);

            var bots = new IBot[]
            {
                smartBot,
                smartBot,
                smartBot,
                smartBot
            };

            const bool saveGamelogFile = true;
            var        simulation      = await BomberjamRunner.StartSimulation(bots, saveGamelogFile);

            while (!simulation.IsFinished)
            {
                await simulation.ExecuteNextTick();
            }

            Console.WriteLine("Simulation completed!");
        }