From 06c61055d43852aae61b9239bf06ffe51962a897 Mon Sep 17 00:00:00 2001 From: dingo Date: Sun, 12 Apr 2026 19:27:16 -0400 Subject: [PATCH] Implement AI Phase 4: Neural MCTS engine for tiers 9-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add NeuralModelRegistry singleton: loads ONNX model from Ai:NeuralModelPath, hot-swap via ReloadAsync(), static Instance for engine access - Add NeuralEvaluator: GameState → ONNX inference with heuristic fallback when no model is loaded (tiers 9-10 fully playable without a trained model) - Add AiNeuralStartupService: loads model at startup, logs if not configured - Add NeuralDecisionEngine: MCTS with neural leaf evaluation (400 sims/action, 6-10s budget) replacing random rollouts with direct score estimation - Set tiers 9-10 EngineType="Neural" in AiDifficultyProfiles - Add AiModelPage (/ai/model): model status, hot-swap button, ONNX contract docs - Register NeuralModelRegistry + NeuralDecisionEngine in SOR.Ai and SOR.Admin - Add Microsoft.ML.OnnxRuntime 1.18.0 to central package versions Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude Co-Authored-By: Happy --- Server/Directory.Packages.props | 3 + .../SOR.Admin/Components/Layout/NavMenu.razor | 5 + .../Components/Pages/Ai/AiModelPage.razor | 123 +++++++++++++++ Server/src/SOR.Admin/Program.cs | 4 + Server/src/SOR.Ai/Core/AiPlayerSession.cs | 1 + .../src/SOR.Ai/Engine/AiDifficultyProfiles.cs | 9 +- .../src/SOR.Ai/Engine/NeuralDecisionEngine.cs | 147 ++++++++++++++++++ .../SOR.Ai/Neural/AiNeuralStartupService.cs | 38 +++++ Server/src/SOR.Ai/Neural/NeuralEvaluator.cs | 83 ++++++++++ .../src/SOR.Ai/Neural/NeuralModelRegistry.cs | 129 +++++++++++++++ Server/src/SOR.Ai/SOR.Ai.csproj | 4 + Server/src/SOR.Ai/ServiceRegistration.cs | 10 +- Server/src/SOR.Ai/Training/SelfPlayRunner.cs | 1 + 13 files changed, 554 insertions(+), 3 deletions(-) create mode 100644 Server/src/SOR.Admin/Components/Pages/Ai/AiModelPage.razor create mode 100644 Server/src/SOR.Ai/Engine/NeuralDecisionEngine.cs create mode 100644 Server/src/SOR.Ai/Neural/AiNeuralStartupService.cs create mode 100644 Server/src/SOR.Ai/Neural/NeuralEvaluator.cs create mode 100644 Server/src/SOR.Ai/Neural/NeuralModelRegistry.cs diff --git a/Server/Directory.Packages.props b/Server/Directory.Packages.props index ecbb97b..4aa7f88 100644 --- a/Server/Directory.Packages.props +++ b/Server/Directory.Packages.props @@ -66,5 +66,8 @@ + + + \ No newline at end of file diff --git a/Server/src/SOR.Admin/Components/Layout/NavMenu.razor b/Server/src/SOR.Admin/Components/Layout/NavMenu.razor index e3f611c..282d077 100644 --- a/Server/src/SOR.Admin/Components/Layout/NavMenu.razor +++ b/Server/src/SOR.Admin/Components/Layout/NavMenu.razor @@ -183,6 +183,11 @@ Deck Config +