-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.c
More file actions
49 lines (39 loc) · 1.23 KB
/
main.c
File metadata and controls
49 lines (39 loc) · 1.23 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include <stdio.h>
#include <stdlib.h>
#include "board.h"
#include "winfunc.h"
#include "mcts.h"
int main(int argc, char *argv[]) {
int rank;
char column;
int row;
int your_color;
GameState state;
initialize_board(&state);
your_color = 1; //you are black stone
bool gameOver = false;
while (!gameOver) {
if (state.current_stone == your_color) {
print_board(&state);
printf("Enter coordinates (e.g., h8): ");
scanf(" %c%d", &column, &row);
add_stone(&state, column, row);
state.current_stone = (state.current_stone == BLACK) ? WHITE : BLACK;
} else {
int max_search = 10000;
int best_action = monte_carlo_tree_search(state, max_search);
make_move(&state, best_action);
}
if (checkWinDebug(&state)) {
print_board(&state);
printf("Player %d wins the game\n", 3 - state.current_stone);
printf("Congratulations!\n");
gameOver = true;
} else if (checkDraw(&state)) {
print_board(&state);
printf("There is no valid place - Draw");
gameOver = true;
}
}
return 0;
}