aboutsummaryrefslogtreecommitdiff
path: root/voerbak/board.c
diff options
context:
space:
mode:
Diffstat (limited to 'voerbak/board.c')
-rw-r--r--voerbak/board.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/voerbak/board.c b/voerbak/board.c
index 8008db4..5bc4bd1 100644
--- a/voerbak/board.c
+++ b/voerbak/board.c
@@ -12,6 +12,12 @@ Board* createBoard(int width, int height) {
return gameBoard;
}
+Board* createCopy(Board* original) {
+ Board *copy = createBoard(original->width, original->height);
+ copy->board = original->board;
+ return copy;
+}
+
void printBoard(Board *b) {
for (int i = 0; i < b->length; i++)
printf("%d", b->board[i]);
@@ -25,17 +31,19 @@ bool boardFull(Board *b) {
return true;
}
-bool dropFisje(Board *b, int column, int disc) {
+int dropFisje(Board *b, int column, int disc) {
for (int row = 0; row < b->height; row++) {
int pos = column + row * b->width;
if (b->board[pos] == 0) {
b->board[pos] = disc;
- bool won = checkWin(b, pos);
- return true; // success
+ /* bool won = checkWin(b, pos); */
+ return pos;
}
}
- printf("e:full\n");
- fflush(stdout);
- return false; // unsuccessful drop on board full
+ if (verbosity >= 0) {
+ printf("e:full\n");
+ fflush(stdout);
+ }
+ return -1;
}