From 84d17dd73a8ef43ef9e284c4455f79f67f7bd98d Mon Sep 17 00:00:00 2001 From: tslil Date: Fri, 8 Jan 2021 17:37:13 -0500 Subject: Fixed a small bug in PTN parsing, other stuff --- include/tak.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'include/tak.c') diff --git a/include/tak.c b/include/tak.c index 1d29694..bb06a16 100644 --- a/include/tak.c +++ b/include/tak.c @@ -319,10 +319,11 @@ check_win(void) { } else { return WIN_ROAD_BLACK; } - } else { + } else if (rw == WIN_ROAD_WHITE) { return rw; } + // Do we do a flat count? int8_t total = 0, board_full = 1; for (uint8_t k = 0; k < NUM_SQUARES; k++) { if (COUNT_AT(k) == 0) { @@ -331,14 +332,14 @@ check_win(void) { total += ((colours[k] & 1) == C_BLACK) ? +1 : -1 ; } } - - // Do we do a flat count? if (black_count == 0 || white_count == 0 || board_full) { // Decide based on count if (total > 0) return WIN_FLAT_BLACK; else if (total < 0) return WIN_FLAT_WHITE; else return WIN_DRAW; } + + return 0xFF; } // =================================================================== // PTN place parser @@ -424,7 +425,7 @@ parse_move(const uint8_t board_size, char *ptn, // assume n = 1 ptn++; if (*ptn == 0) { - *out_steps = picked_up; + *out_steps = 1; out_drops[0] = picked_up; return PTN_VALID; } @@ -556,7 +557,11 @@ do_ptn(char *ptn) { // more conservative here :) if (ply >= board_size) { won = check_win(); - if (won < 0xFF) return GAME_END; + if (won < 0xFF) { + // Winning move, but no need to update current colour + ply++; + return GAME_END; + } } // Only step if the game isn't over yet next_ply(); -- cgit v1.2.3