aboutsummaryrefslogtreecommitdiff
path: root/src/pptdb.c
diff options
context:
space:
mode:
authortslil clingman <tslil@posteo.de>2021-01-18 13:43:49 -0500
committertslil <tslil@posteo.de>2026-08-28 19:37:41 +0100
commita8f69f1262bd76ab311ebe760f314fa6e4526d15 (patch)
treee022deb4b4c801a3fb2538c188352e9c5fe00ddc /src/pptdb.c
parent092d01aa766f2f7fd7e9bbceaf71cff29188b328 (diff)
Toying with symmetrising data
Diffstat (limited to 'src/pptdb.c')
-rw-r--r--src/pptdb.c53
1 files changed, 34 insertions, 19 deletions
diff --git a/src/pptdb.c b/src/pptdb.c
index b1d91ce..5c5c718 100644
--- a/src/pptdb.c
+++ b/src/pptdb.c
@@ -12,7 +12,7 @@ int generate, outcome_black;
const int max_depth = 6;
static void
-write_input(void) {
+write_input(const int dx, const int dy) {
// Two numbers for flats remaining
fprintf(training_fh,"%.8f,%.8f,",
(float)(white_count & 127)/max_flats,
@@ -20,28 +20,37 @@ write_input(void) {
// Write the board layers
float val;
+ int col, row;
for (uint8_t depth = 0; depth < max_depth; depth++) {
- for (uint8_t k = 0; k < board_size * board_size; k++) {
- val = 0;
- if (COUNT_AT(k)>depth) {
- if (depth == 0) {
- // Top layer of stacks is handled differently to indicate
- // stone type
- if (STONE_AT(k) == STONE_STANDING) {
- val = (colours[k] & 1) ? +0.25 : -0.25;
- } else if (STONE_AT(k) == STONE_CAPSTONE) {
- val = (colours[k] & 1) ? +1.00 : -1.00;
+ row = (dy>0)?-1:board_size;
+ for (int i = 0; i < board_size; i++) {
+ row += dy;
+ col = (dx>0)?-1:board_size;
+ for (int j = 0; j < board_size; j++) {
+ col += dx;
+ const uint8_t k = THE_COORDS(col, row);
+ val = 0;
+ if (COUNT_AT(k)>depth) {
+ if (depth == 0) {
+ // Top layer of stacks is handled differently to indicate
+ // stone type
+ if (STONE_AT(k) == STONE_STANDING) {
+ val = (colours[k] & 1) ? +0.25 : -0.25;
+ } else if (STONE_AT(k) == STONE_CAPSTONE) {
+ val = (colours[k] & 1) ? +1.00 : -1.00;
+ } else {
+ val = (colours[k] & 1) ? +0.50 : -0.50;
+ }
} else {
- val = (colours[k] & 1) ? +0.50 : -0.50;
+ // Layers underneath
+ val = (colours[k] & (1<<depth)) ? +0.50 : -0.50;
}
- } else {
- // Layers underneath
- val = (colours[k] & (1<<depth)) ? +0.50 : -0.50;
}
+ fprintf(training_fh,"%.2f,", val);
}
- fprintf(training_fh,"%.2f,", val);
}
}
+ fprintf(training_fh,"%d\n", outcome_black);
}
// Warning: performs _no_ checks on input whatsoever
@@ -106,8 +115,14 @@ parse_line(const char *pt, const ssize_t read) {
}
// Generate training data, not too early in the game
if (generate && ply + 4 >= total_plies) {
- write_input();
- fprintf(training_fh,"%d\n", outcome_black);
+ /*
+ * int dx = (rand()&1)?-1:+1;
+ * int dy = (rand()&1)?-1:+1;
+ */
+ write_input(1,1);
+ write_input(1,-1);
+ write_input(-1,1);
+ write_input(-1,-1);
}
// Parse next action
while (idx<read && pt[idx++]!=',');
@@ -204,7 +219,7 @@ main(int argc, char **argv) {
Black wins: %.3f%%\n\
Road wins: %d\nFlat wins: %d\n\
Average turns to road win: %.3f\n\
-Average turns to flat win: %f\n",
+Average turns to flat win: %.3f\n",
illegal, overflow,
(double)black_wins / (double)(black_wins+white_wins) * 100,
road_wins, flat_wins,