aboutsummaryrefslogtreecommitdiff
path: root/voerbak/voerbak.c
diff options
context:
space:
mode:
Diffstat (limited to 'voerbak/voerbak.c')
-rw-r--r--voerbak/voerbak.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/voerbak/voerbak.c b/voerbak/voerbak.c
index d1982fa..2782163 100644
--- a/voerbak/voerbak.c
+++ b/voerbak/voerbak.c
@@ -6,6 +6,7 @@
#include "board.h"
#include "messages.h"
#include "argparse.h"
+#include "solvers.h"
#define EMPTY ""
@@ -14,6 +15,7 @@ int main(int argc, char* argv[]) {
Board *gameBoard = createBoard(arguments.width, arguments.height);
+ bool cpu_2 = strlen(arguments.solver) > 0;
bool player_1 = true;
int move = 0;
char* message = malloc(1); // this is weird and i don't understand it but it prevents a segmentation fault or something
@@ -26,13 +28,15 @@ int main(int argc, char* argv[]) {
continue;
}
+ move:
+
if (move == 0) break;
if (move < 1 || move > gameBoard->width) continue;
bool dropSuccess = dropFisje(gameBoard, move - 1, player_1 + 1);
player_1 = player_1 ^ dropSuccess; // only flip turns on successful drop
- printf("m:%s\n", player_1 ? "true" : "false");
+ !cpu_2 && printf("m:%s\n", player_1 ? "true" : "false");
fflush(stdout);
if (boardFull(gameBoard)) {
@@ -41,6 +45,11 @@ int main(int argc, char* argv[]) {
}
printBoard(gameBoard);
+
+ if (cpu_2 && !player_1) {
+ move = cpuMove(gameBoard, arguments.solver);
+ goto move;
+ }
}
return 0;