Spaces:
Sleeping
Sleeping
| import { TrigoGame } from "../inc/trigo/game"; | |
| // Test case: 2x3 board with moves aa zz z0 a0 | |
| // Expected: NOT terminal | |
| console.log("=== Test: 2x3 board - aa zz z0 a0 ===\n"); | |
| // 2x3x1 board layout: | |
| // y=2: az zz | |
| // y=1: a0 z0 | |
| // y=0: aa za | |
| // x=0 x=1 | |
| // For 2x3 board notation: | |
| // x: a(0), z(1) | |
| // y: a(0), 0(1), z(2) | |
| const game = new TrigoGame({ x: 2, y: 3, z: 1 }); | |
| game.startGame(); | |
| console.log("Board shape: 2x3x1"); | |
| console.log("Position notation:"); | |
| console.log(" y=2: az(0,2) zz(1,2)"); | |
| console.log(" y=1: a0(0,1) z0(1,1)"); | |
| console.log(" y=0: aa(0,0) za(1,0)"); | |
| console.log(); | |
| // Moves: aa zz z0 a0 | |
| const moves = [ | |
| { pos: { x: 0, y: 0, z: 0 }, name: "aa" }, // Black | |
| { pos: { x: 1, y: 2, z: 0 }, name: "zz" }, // White | |
| { pos: { x: 1, y: 1, z: 0 }, name: "z0" }, // Black | |
| { pos: { x: 0, y: 1, z: 0 }, name: "a0" }, // White | |
| ]; | |
| for (let i = 0; i < moves.length; i++) { | |
| const move = moves[i]; | |
| const player = i % 2 === 0 ? "Black" : "White"; | |
| const success = game.drop(move.pos); | |
| console.log(`${i + 1}. ${player}: ${move.name} (${move.pos.x},${move.pos.y}) - ${success ? "OK" : "FAILED"}`); | |
| } | |
| // Show board state | |
| console.log("\nBoard state:"); | |
| const board = game.getBoard(); | |
| for (let y = 2; y >= 0; y--) { | |
| let row = `y=${y}: `; | |
| for (let x = 0; x < 2; x++) { | |
| const stone = board[x][y][0]; | |
| const mark = stone === 0 ? "." : (stone === 1 ? "B" : "W"); | |
| row += mark + " "; | |
| } | |
| console.log(row); | |
| } | |
| // Check terminal conditions | |
| const territory = game.getTerritory(); | |
| console.log("\nTerritory:", { black: territory.black, white: territory.white, neutral: territory.neutral }); | |
| const hasCapture = game.hasCapturingMove(); | |
| console.log("hasCapturingMove():", hasCapture); | |
| const validMoves = game.validMovePositions(); | |
| console.log("validMovePositions():", validMoves.length); | |
| // Count coverage | |
| let stoneCount = 0; | |
| for (let x = 0; x < 2; x++) { | |
| for (let y = 0; y < 3; y++) { | |
| if (board[x][y][0] !== 0) stoneCount++; | |
| } | |
| } | |
| const coverage = stoneCount / 6; | |
| console.log("Coverage:", (coverage * 100).toFixed(1) + "%"); | |
| console.log("\n" + "=".repeat(50)); | |
| console.log("Terminal check:"); | |
| console.log(" - neutral == 0?", territory.neutral === 0); | |
| console.log(" - coverage > 50%?", coverage > 0.5); | |
| console.log(" - hasCapturingMove?", hasCapture); | |
| const shouldBeTerminal = territory.neutral === 0 && coverage > 0.5 && !hasCapture; | |
| console.log("\nWith current logic, isTerminal:", shouldBeTerminal); | |
| console.log("Expected: false (NOT terminal)"); | |
| console.log("Test", shouldBeTerminal === false ? "PASSED ✓" : "FAILED ✗"); | |