X-Git-Url: https://git.notmuchmail.org/git?a=blobdiff_plain;f=dvonn-board.c;h=4d09e13be58f0ce25f2ee048bca2ea11391ee2b5;hb=1e29ece3252138d372b47499dd4c77f01413c7fc;hp=f80277531ee7a8ee9bf71ba616a2e8c2ca69ea45;hpb=2c8c385d00f60fad7a4b74b0b66516fbce62c50f;p=dvonn diff --git a/dvonn-board.c b/dvonn-board.c index f802775..4d09e13 100644 --- a/dvonn-board.c +++ b/dvonn-board.c @@ -63,6 +63,7 @@ dvonn_board_init (dvonn_board_t *board) for (y = 0; y < DVONN_BOARD_Y_SIZE; y++) { board->cells[x][y].type = DVONN_CELL_EMPTY; board->cells[x][y].height = 0; + board->cells[x][y].contains_red = FALSE; } } @@ -140,12 +141,14 @@ dvonn_board_place (dvonn_board_t *board, return FALSE; } - if (board->moves < 3) + if (board->moves < 3) { board->cells[x][y].type = DVONN_CELL_RED; - else if (board->moves % 2) + board->cells[x][y].contains_red = TRUE; + } else if (board->moves % 2) { board->cells[x][y].type = DVONN_CELL_BLACK; - else + } else { board->cells[x][y].type = DVONN_CELL_WHITE; + } board->cells[x][y].height = 1; @@ -175,9 +178,11 @@ dvonn_board_move (dvonn_board_t *board, board->cells[x2][y2].height += board->cells[x1][y1].height; board->cells[x2][y2].type = board->cells[x1][y1].type; + board->cells[x2][y2].contains_red |= board->cells[x1][y1].contains_red; board->cells[x1][y1].type = DVONN_CELL_EMPTY; board->cells[x1][y1].height = 0; + board->cells[x1][y1].contains_red = FALSE; dvonn_board_next_player (board);