diff options
| author | tslil <tslil@posteo.de> | 2021-01-08 17:37:13 -0500 |
|---|---|---|
| committer | tslil <tslil@posteo.de> | 2026-08-28 19:37:41 +0100 |
| commit | 84d17dd73a8ef43ef9e284c4455f79f67f7bd98d (patch) | |
| tree | 157ad18698970d888e91b588ea5c1a8aae77ba71 /include/tak.c | |
| parent | e8315ed893157a87c8f2c3935667ffcc97b2c95e (diff) | |
Fixed a small bug in PTN parsing, other stuff
Diffstat (limited to 'include/tak.c')
| -rw-r--r-- | include/tak.c | 15 |
1 files changed, 10 insertions, 5 deletions
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(); |
