aboutsummaryrefslogtreecommitdiff
path: root/voerbak/board.c
diff options
context:
space:
mode:
authorlonkaars <l.leblansch@gmail.com>2021-02-26 11:16:17 +0100
committerlonkaars <l.leblansch@gmail.com>2021-02-26 11:16:17 +0100
commit16983d110e90972ceed4ca6d65473d038c9cb854 (patch)
tree6518252492f186186b1446cb85f65fd60609c980 /voerbak/board.c
parent4979a5ec8b88f7a385b7ec6ed5a26bbcfe4ff7f3 (diff)
diewertje beginnings
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;
}