From 27c0576e25226dc75636c372aff3c0818af03201 Mon Sep 17 00:00:00 2001 From: tslil Date: Thu, 7 Jan 2021 16:49:20 -0500 Subject: Check for road wins before flat wins --- extract.sh | 15 +++++++-------- include/tak.c | 29 ++++++++++++++--------------- 2 files changed, 21 insertions(+), 23 deletions(-) diff --git a/extract.sh b/extract.sh index e091a9c..d351244 100755 --- a/extract.sh +++ b/extract.sh @@ -4,20 +4,19 @@ db_file=games_anon.db query() { echo "SELECT $1 FROM games WHERE (size == $2) \ -and (result != '1-0') and (result != '0-1') and (result != '0-0')\ -and (result != '1/2-1/2');" +and ((result == 'R-0') or (result == '0-R'));" +# and (result != '1-0') and (result != '0-1') and (result != '0-0')\ +# and (result != '1/2-1/2');" } extract() { - cd data - if [ ! -f "$db_file" ]; then - wget "https://www.playtak.com/games_anon.db" + if [ ! -f "data/$db_file" ]; then + wget "https://www.playtak.com/games_anon.db" -O "data/$db_file" fi - for size in 5 6; do + for size in 5; do echo Extracing games of size "$size"... - sqlite3 "$db_file" "$(query $1 $size)" | shuf > "playtak-$size" + sqlite3 "data/$db_file" "$(query $1 $size)" | shuf > "data/playtak-$size" done - cd .. } process() { diff --git a/include/tak.c b/include/tak.c index 5551e5b..1d29694 100644 --- a/include/tak.c +++ b/include/tak.c @@ -308,6 +308,20 @@ check_road_colour(const enum COLOUR colour) { enum WIN_TYPE check_win(void) { + // Road? + enum WIN_TYPE rb, rw; + rb = check_road_colour(C_BLACK); + rw = check_road_colour(C_WHITE); + + if (rb == WIN_ROAD_BLACK) { + if (rw == WIN_ROAD_WHITE) { + return WIN_DRAGON; + } else { + return WIN_ROAD_BLACK; + } + } else { + return rw; + } int8_t total = 0, board_full = 1; for (uint8_t k = 0; k < NUM_SQUARES; k++) { @@ -325,21 +339,6 @@ check_win(void) { else if (total < 0) return WIN_FLAT_WHITE; else return WIN_DRAW; } - - // Road? - enum WIN_TYPE rb, rw; - rb = check_road_colour(C_BLACK); - rw = check_road_colour(C_WHITE); - - if (rb == WIN_ROAD_BLACK) { - if (rw == WIN_ROAD_WHITE) { - return WIN_DRAGON; - } else { - return WIN_ROAD_BLACK; - } - } else { - return rw; - } } // =================================================================== // PTN place parser -- cgit v1.2.3