From c2227f2c115ee536ffa22b32866d3a68437dba73 Mon Sep 17 00:00:00 2001 From: tslil Date: Wed, 6 Jan 2021 00:43:18 -0500 Subject: On the hunt for a better representation --- src/pptdb.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'src/pptdb.c') diff --git a/src/pptdb.c b/src/pptdb.c index 712aabc..7a26ffd 100644 --- a/src/pptdb.c +++ b/src/pptdb.c @@ -19,28 +19,29 @@ write_input(void) { // Two layers of board_size * board_size: float t; int h; uint16_t mask; for (int k = 0; k < board_size * board_size; k++) { - // stacks encoded as balanced ternary, without caps and walls + // stacks encoded as balanced ternary t = 0; h = COUNT_AT(k); + if (h>0) { mask = 1<<(h-1); - /* if (STONE_AT(k) != STONE_FLAT) h--; */ while (h-->0) { - t += (colours[k] & mask) ? +1.0 : -1.0; - t /= 3; + t += (colours[k] & mask) ? +1 : -1; + t/=3; mask >>= 1; } } fprintf(training_fh,"%.6f,",t); } - int val; + float val; for (int k = 0; k < board_size * board_size; k++) { val = 0; if (COUNT_AT(k)) { - if (STONE_AT(k) == STONE_STANDING) val = (colours[k] & 1) ? +1 : -1; - else if (STONE_AT(k) == STONE_CAPSTONE) val = (colours[k] & 1) ? +2 : -2; + if (STONE_AT(k) == STONE_STANDING) val = (colours[k] & 1) ? +1/3 : -1/3; + else if (STONE_AT(k) == STONE_CAPSTONE) val = (colours[k] & 1) ? +1.0 : -1.0; + else val = (colours[k] & 1) ? +2/3 : -2/3; } - fprintf(training_fh,"%d,",val); + fprintf(training_fh,"%.6f,",val); } } -- cgit v1.2.3