From 2ef0078ba2afd99c4fc2673497f3d3a39119cf5d Mon Sep 17 00:00:00 2001 From: tslil Date: Wed, 13 Jan 2021 16:39:16 -0500 Subject: Trying minimax --- include/tak.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'include/tak.c') diff --git a/include/tak.c b/include/tak.c index dc402d4..57dacf7 100644 --- a/include/tak.c +++ b/include/tak.c @@ -151,8 +151,11 @@ try_move(const int8_t location, const enum MOVE_DIRECTION direction, }; case M_LEFT: { delta = -1; - if ((location + steps * delta) / board_size - < location / board_size) + // We need the extra check for zero here because, irritatingly, + // -1 / board_size == 1 / board_size + if ((location + steps * delta < 0) || + ((location + steps * delta) / board_size + < location / board_size)) return ACT_ILLEGAL; break; }; @@ -469,7 +472,7 @@ parse_move(const uint8_t board_size, char *ptn, // =================================================================== void -generate_place(const uint8_t board_size, const uint8_t in_location, +generate_place(const uint8_t in_location, const enum STONE_VARIANT in_stone, char out_ptn[4]) { switch (in_stone) { case STONE_FLAT: { break; } @@ -486,7 +489,7 @@ generate_place(const uint8_t board_size, const uint8_t in_location, // =================================================================== void -generate_move(const uint8_t board_size, const uint8_t in_location, +generate_move(const uint8_t in_location, const enum MOVE_DIRECTION in_direction, const uint8_t in_steps, const uint8_t in_drops[5], char out_ptn[10]) { -- cgit v1.2.3