Spaces:
Sleeping
Sleeping
| /** | |
| * Replay and analyze the latest 5x1x1 game | |
| */ | |
| import { TrigoGame } from "../inc/trigo/game.js"; | |
| function analyzeGame() { | |
| console.log("================================================================================"); | |
| console.log("Analyzing Game: game_e0ceb960fe741704.tgn"); | |
| console.log("================================================================================\n"); | |
| const game = new TrigoGame({ x: 5, y: 1, z: 1 }); | |
| game.startGame(); | |
| console.log("Board positions: a(0) - b(1) - 0(2) - y(3) - z(4)\n"); | |
| // Move 1: a 0 | |
| console.log("Move 1a: Black plays a(0)"); | |
| game.drop({ x: 0, y: 0, z: 0 }); | |
| console.log(" Board:", game.getBoard().flat().flat()); | |
| console.log(" Territory:", game.getTerritory()); | |
| console.log(" Game status:", game.getGameStatus()); | |
| console.log("\nMove 1b: White plays 0(2)"); | |
| game.drop({ x: 2, y: 0, z: 0 }); | |
| console.log(" Board:", game.getBoard().flat().flat()); | |
| console.log(" Territory:", game.getTerritory()); | |
| console.log(" Valid moves for Black:", game.validMovePositions()); | |
| // Move 2: y z | |
| console.log("\nMove 2a: Black plays y(3)"); | |
| game.drop({ x: 3, y: 0, z: 0 }); | |
| console.log(" Board:", game.getBoard().flat().flat()); | |
| console.log(" Territory:", game.getTerritory()); | |
| console.log("\nMove 2b: White plays z(4)"); | |
| game.drop({ x: 4, y: 0, z: 0 }); | |
| console.log(" Board:", game.getBoard().flat().flat()); | |
| console.log(" Territory:", game.getTerritory()); | |
| // Move 3: Pass y | |
| console.log("\nMove 3a: Black Pass"); | |
| game.pass(); | |
| console.log(" Board:", game.getBoard().flat().flat()); | |
| console.log(" Territory:", game.getTerritory()); | |
| console.log(" Game status:", game.getGameStatus()); | |
| console.log("\nMove 3b: White plays y(3)"); | |
| try { | |
| game.drop({ x: 3, y: 0, z: 0 }); | |
| console.log(" Board:", game.getBoard().flat().flat()); | |
| console.log(" Territory:", game.getTerritory()); | |
| } catch (error: any) { | |
| console.log(" ERROR:", error.message); | |
| } | |
| // Move 4: b | |
| console.log("\nMove 4a: Black plays b(1)"); | |
| try { | |
| game.drop({ x: 1, y: 0, z: 0 }); | |
| console.log(" Board:", game.getBoard().flat().flat()); | |
| console.log(" Territory:", game.getTerritory()); | |
| console.log(" Game status:", game.getGameStatus()); | |
| } catch (error: any) { | |
| console.log(" ERROR:", error.message); | |
| } | |
| // Check if game should be terminal | |
| console.log("\n" + "=".repeat(80)); | |
| console.log("Final Analysis:"); | |
| console.log("=".repeat(80)); | |
| const territory = game.getTerritory(); | |
| console.log("Territory:", territory); | |
| console.log("Game status:", game.getGameStatus()); | |
| console.log("\nChecking capture possibilities:"); | |
| const blackCanCapture = game.hasCapturingMove(1); | |
| const whiteCanCapture = game.hasCapturingMove(2); | |
| console.log(" Black can capture?", blackCanCapture); | |
| console.log(" White can capture?", whiteCanCapture); | |
| console.log("\nValid moves:"); | |
| console.log(" White:", game.validMovePositions()); | |
| if (territory.neutral === 0 && !blackCanCapture && !whiteCanCapture) { | |
| console.log("\n✅ Game is truly terminal (no neutral territory, no captures possible)"); | |
| } else { | |
| console.log("\n⚠️ Game should NOT be terminal yet!"); | |
| if (territory.neutral > 0) { | |
| console.log(" Reason: Still has neutral territory"); | |
| } | |
| if (blackCanCapture || whiteCanCapture) { | |
| console.log(" Reason: Capture moves still available"); | |
| } | |
| } | |
| } | |
| analyzeGame(); | |