-
Notifications
You must be signed in to change notification settings - Fork 0
/
testminimax.cpp
51 lines (43 loc) · 1.58 KB
/
testminimax.cpp
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
#include <iostream>
#include "common.hpp"
#include "player.hpp"
#include "board.hpp"
// Use this file to test your minimax implementation (2-ply depth, with a
// heuristic of the difference in number of pieces).
int main(int argc, char *argv[]) {
// Create board with example state. You do not necessarily need to use
// this, but it's provided for convenience.
char boardData[64] = {
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
' ', 'b', ' ', ' ', ' ', ' ', ' ', ' ',
'b', 'w', 'b', 'b', 'b', 'b', ' ', ' ',
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '
};
Board *board = new Board();
board->setBoard(boardData);
// Initialize player as the white player, and set testing_minimax flag.
Player *player = new Player(WHITE);
player->testingMinimax = true;
/**
* TODO: Write code to set your player's internal board state to the
* example state.
*/
// Get player's move and check if it's right.
Move *move = player->doMove(nullptr, 0);
if (move != nullptr && move->x == 1 && move->y == 1) {
std::cout << "Correct move: (1, 1)" << std::endl;;
} else {
std::cout << "Wrong move: got ";
if (move == nullptr) {
std::cout << "PASS";
} else {
std::cout << "(" << move->x << ", " << move->y << ")";
}
std::cout << ", expected (1, 1)" << std::endl;
}
return 0;
}