aboutsummaryrefslogtreecommitdiff
path: root/src/pptdb.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/pptdb.c')
-rw-r--r--src/pptdb.c54
1 files changed, 14 insertions, 40 deletions
diff --git a/src/pptdb.c b/src/pptdb.c
index 5711dc7..773962f 100644
--- a/src/pptdb.c
+++ b/src/pptdb.c
@@ -13,9 +13,6 @@ const int max_depth = 8;
static void
write_input(void) {
- // Whose turn is it?
- /* fprintf(training_fh,"%d,",current_colour == C_BLACK); */
-
// Two numbers for flats remaining
fprintf(training_fh,"%.8f,%.8f,",
(float)(white_count & 127)/max_flats,
@@ -23,13 +20,13 @@ write_input(void) {
// Write the board layers
float val;
- for (int depth = 0; depth < max_depth; depth++) {
- for (int k = 0; k < board_size * board_size; k++) {
+ for (uint8_t depth = 0; depth < max_depth; depth++) {
+ for (uint8_t k = 0; k < board_size * board_size; k++) {
val = 0;
- if (depth == 0) {
- // Top layer of stacks is handled differently to indicate
- // stone type
- if (COUNT_AT(k)>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) {
@@ -39,29 +36,12 @@ write_input(void) {
}
} else {
// Layers underneath
- if (COUNT_AT(k)>depth) val = (colours[k] & (1<<depth)) ? +0.50 : -0.50;
+ val = (colours[k] & (1<<depth)) ? +0.50 : -0.50;
}
}
fprintf(training_fh,"%.2f,", val);
}
}
-
- /*
- * float t;
- * for (int k = 0; k < board_size * board_size; k++) {
- * // stacks encoded as balanced ternary
- * const int h = COUNT_AT(k);
- * t = 0;
- * mask = 1<<h;
- * for (int j = 1; j < h; j++) {
- * t += (colours[k] & mask) ? +1 : -1;
- * t /= 3.0;
- * mask >>=1;
- * }
- * fprintf(training_fh,"%.8f,",2*t);
- * }
- */
-
}
// Warning: performs _no_ checks on input whatsoever
@@ -89,11 +69,9 @@ parse_line(const char *pt, const ssize_t read) {
r = try_place(THE_COORDS(col,row), current_colour, stone);
if (r != ACT_OK) return r;
- /*
- * char buf[20];
- * generate_place(board_size, THE_COORDS(col,row), stone, buf);
- * puts(buf);
- */
+ char buf[20];
+ generate_place(board_size, THE_COORDS(col,row), stone, buf);
+ puts(buf);
} else if (pt[idx] == 'M') {
// M [A-F][1-6] [A-F][1-6]( [1-6])+,
@@ -126,16 +104,12 @@ parse_line(const char *pt, const ssize_t read) {
}
}
- /*
- * char buf[20];
- * generate_move(board_size, THE_COORDS(s_col, s_row), dir, steps, drops, buf);
- * puts(buf);
- */
+ char buf[20];
+ generate_move(board_size, THE_COORDS(s_col, s_row), dir, steps, drops, buf);
+ puts(buf);
}
- /*
- * if (current_colour == C_BLACK && ply > 15) puts("Here");
- */
+ if (current_colour == C_BLACK && ply > 15) puts("Here");
// Generate training data, not too early in the game
if (generate && current_colour == C_BLACK && ply > 15) {