diff options
| author | tslil <tslil@posteo.de> | 2021-03-28 00:22:26 -0400 |
|---|---|---|
| committer | tslil <tslil@posteo.de> | 2026-08-28 19:37:41 +0100 |
| commit | 29536c86457d83967c23a900574182b3898f04dd (patch) | |
| tree | 9fa6e2324ebb40d1939f1c106bdfe55b5f80de10 | |
| parent | 2dbb9fa9b69e49d49cebb1c17559f6fe67600a4d (diff) | |
| parent | c9823c76dd43aa40bef3f67fa0940a78cb40bf05 (diff) | |
Merge branch 'master' of git.sr.ht:~tslil/ctak
| -rwxr-xr-x | resources/extract.sh | 2 | ||||
| -rw-r--r-- | src/cnn_train.py | 2 | ||||
| -rw-r--r-- | src/pptdb.c | 16 |
3 files changed, 10 insertions, 10 deletions
diff --git a/resources/extract.sh b/resources/extract.sh index 0d92ad4..2c4b153 100755 --- a/resources/extract.sh +++ b/resources/extract.sh @@ -61,7 +61,7 @@ fi make pptdb -for size in 5; do +for size in 6; do echo extract $size notation,result process $size 1000000 training diff --git a/src/cnn_train.py b/src/cnn_train.py index 111aa76..4ba0a0b 100644 --- a/src/cnn_train.py +++ b/src/cnn_train.py @@ -1,4 +1,4 @@ -# train5.py, train a small CNN to recognise winning Tak positions +# cnn_train.py, train a small CNN to recognise winning Tak positions # # Copyright (C) 2021, tslil clingman # diff --git a/src/pptdb.c b/src/pptdb.c index 8684c47..79f60c5 100644 --- a/src/pptdb.c +++ b/src/pptdb.c @@ -29,8 +29,6 @@ uint64_t heights[16]; FILE *training_fh = NULL; float max_flats, outcome_black; -const int max_depth = 6; - static void write_input(const int dx, const int dy, const uint8_t swap) { // Two numbers for flats remaining @@ -41,7 +39,7 @@ write_input(const int dx, const int dy, const uint8_t swap) { // Write the board layers float val; int col, row; - for (uint8_t depth = 0; depth < max_depth; depth++) { + for (uint8_t depth = 0; depth < board_size + 1; depth++) { row = (dy>0)?-1:board_size; for (int i = 0; i < board_size; i++) { row += dy; @@ -134,11 +132,13 @@ parse_line(const char *pt, const ssize_t read) { } } } - // Generate training data, not too early in the game, all - // orientations - if (generate && ply + 3 >= total_plies) { -#define RANDPM1 ((rand()&1)?-1:+1) - write_input(RANDPM1, RANDPM1, rand()&1); + // Generate training data, not too early in the game and not at + // the end, under all eight symmetries of the board + if (generate && ply < total_plies && ply + 2 >= total_plies) { + write_input(+1, +1, 1); write_input(+1, +1, 0); + write_input(+1, -1, 1); write_input(+1, -1, 0); + write_input(-1, +1, 1); write_input(-1, +1, 0); + write_input(-1, -1, 1); write_input(-1, -1, 0); } // Parse next action while (idx<read && pt[idx++]!=','); |
