-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug-chess.js
More file actions
35 lines (27 loc) · 1.02 KB
/
debug-chess.js
File metadata and controls
35 lines (27 loc) · 1.02 KB
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
import { Chess } from 'chess.js';
console.log("Starting debug script...");
try {
const game = new Chess();
console.log("Initial FEN:", game.fen());
const move = { from: 'e2', to: 'e4' };
console.log("Attempting move:", move);
// Test logic from Game.jsx
const result = game.move(move);
console.log("Move result:", result);
console.log("FEN after move:", game.fen());
// Test computer logic
const gameCopy = new Chess(game.fen());
const moves = gameCopy.moves();
console.log("Possible moves for computer:", moves.length);
if (moves.length > 0) {
const randomMove = moves[Math.floor(Math.random() * moves.length)];
console.log("Computer logic chose:", randomMove);
const compResult = gameCopy.move(randomMove);
console.log("Computer move result:", compResult);
console.log("Final FEN:", gameCopy.fen());
} else {
console.log("No moves available for computer");
}
} catch (e) {
console.error("Error in debug script:", e);
}