aboutsummaryrefslogtreecommitdiff
path: root/include/tak.c
diff options
context:
space:
mode:
authortslil <tslil@posteo.de>2021-01-13 16:39:16 -0500
committertslil <tslil@posteo.de>2026-08-28 19:37:41 +0100
commit2ef0078ba2afd99c4fc2673497f3d3a39119cf5d (patch)
tree3f3c791ee9b0136270f6cae2de3d96fce18e6a5c /include/tak.c
parentaff5fe7f343194366beeda700a2f4a383e40fa73 (diff)
Trying minimax
Diffstat (limited to 'include/tak.c')
-rw-r--r--include/tak.c11
1 files changed, 7 insertions, 4 deletions
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]) {