File size: 3,346 Bytes
15f353f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/**
 * 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();