diff options
| author | tslil <tslil@posteo.de> | 2021-01-13 23:41:32 -0500 |
|---|---|---|
| committer | tslil <tslil@posteo.de> | 2026-08-28 19:37:41 +0100 |
| commit | cf7d665598e34e32d258775b583968e758c8f2fb (patch) | |
| tree | 6bfda86535ffa051afd8ccfd70f1d4488701dfdf /include/tak.c | |
| parent | 2ef0078ba2afd99c4fc2673497f3d3a39119cf5d (diff) | |
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
Diffstat (limited to 'include/tak.c')
| -rw-r--r-- | include/tak.c | 8 |
1 files changed, 6 insertions, 2 deletions
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 |
