From cf7d665598e34e32d258775b583968e758c8f2fb Mon Sep 17 00:00:00 2001 From: tslil Date: Wed, 13 Jan 2021 23:41:32 -0500 Subject: Fixed minimax (!), fixed bugs in tak.c With minimax of depth 1 the evaluation function seems alright with the current method of training and generating weights --- include/tak.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'include/tak.c') diff --git a/include/tak.c b/include/tak.c index 57dacf7..657df9d 100644 --- a/include/tak.c +++ b/include/tak.c @@ -127,6 +127,11 @@ try_move(const int8_t location, const enum MOVE_DIRECTION direction, if (won < 0xFF) return GAME_END; // Can't do this if (steps == 0 || steps > 5) return ACT_ILLEGAL; + // Check for stones at all + const uint8_t avail = COUNT_AT(location); + if (avail == 0) return ACT_ILLEGAL; + // Does the current player own the pile? + if ((colours[location] & 1) != current_colour) return ACT_ILLEGAL; // Is the desired direction and count on the board? int8_t delta = 0; switch (direction) { @@ -188,8 +193,7 @@ try_move(const int8_t location, const enum MOVE_DIRECTION direction, } // Can't ask to move 0, more than board_size, or stones available - if ( (total == 0) || (total > board_size) - || (total > COUNT_AT(location)) ) + if ( (total == 0) || (total > board_size) || (total > avail) ) return ACT_ILLEGAL; // Nothing illegal, do it. First we add the stones to the -- cgit v1.2.3