-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathminimax.js
More file actions
30 lines (24 loc) · 780 Bytes
/
minimax.js
File metadata and controls
30 lines (24 loc) · 780 Bytes
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
let myColor = readline();
if (myColor === 'w') {
myColor = 'r';
}
let board = new Board(constants.BOARD_LENGTH, constants.BOARD_LENGTH, new NaiveHeuristic(), myColor);
let ai = new AI(board, myColor, constants.DEPTH);
while (true) {
for (let i = 0; i < constants.BOARD_LENGTH; i++) {
const inputLine = readline();
for (let j = 0; j < inputLine.length; j++) {
board.data[i][j] = inputLine[j];
}
}
const numLegalMoves = parseInt(readline());
for (let i = 0; i < numLegalMoves; i++) {
const moveString = readline();
}
console.error(board.toString());
let legalMoves = board.getLegalMoves(myColor);
if (numLegalMoves !== legalMoves.length) {
console.error("YOUR MOVES DONT MATCH");
}
console.log(ai.determineMove().toString());
}