// 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}"); }
public static void DoExam <T>(ISmartBot <T> smartBot) where T : LabeledDataPoint { smartBot.Load(modelSavePath); var score = 0; foreach (var data in ExamData) { var isInactive = smartBot.Predict(smartBot.ExtractDataPoint(data.Data)); if (isInactive == data.IsUnused) { ++score; } } Console.WriteLine($"Score: {score}/{ExamData.Count}"); }
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!"); }
// Train, get metrics and save your Machine Learning Bot private static async Task TrainAndSave <T>(ISmartBot <T> smartBot) where T : LabeledDataPoint { smartBot.Train(gameLogsPath); await smartBot.Save(modelSavePath); }
// Train, get metrics and save your Machine Learning Bot private static async Task TestModel <T>(ISmartBot <T> smartBot) where T : LabeledDataPoint { smartBot.Train(gameLogsPath, true); await SimulatGamesScore(smartBot); }
// https://docs.microsoft.com/en-us/dotnet/machine-learning/how-to-guides/explain-machine-learning-model-permutation-feature-importance-ml-net // Currently only support impact on the LightGbm private static void EvaluateFeatures <T>(ISmartBot <T> smartBot) where T : LabeledDataPoint { smartBot.EvaluateFeatures(gameLogsPath); }
private static async Task Game <T>(ISmartBot <T> smartBot) where T : LabeledDataPoint { await smartBot.Load(modelSavePath); await PlayInBrowserExample(smartBot); }
// https://docs.microsoft.com/en-us/dotnet/machine-learning/how-to-guides/explain-machine-learning-model-permutation-feature-importance-ml-net // Currently only support impact LightGbm algo public static void EvaluateFeatures <T>(ISmartBot <T> smartBot) where T : LabeledDataPoint { smartBot.EvaluateFeatures(dataPath); }
public static async Task TestModel <T>(ISmartBot <T> smartBot) where T : LabeledDataPoint { smartBot.Train(dataPath, true); await smartBot.Save(modelSavePath); }