summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortslil <tslil@posteo.de>2021-01-11 17:24:58 -0500
committertslil <tslil@posteo.de>2026-08-28 19:37:41 +0100
commit0ed59835decdc839d58463cc16441be7a4cb36e2 (patch)
treee5529a5ec5e5423de2c6140d0dbc16d6dd9c0a72
parentfff35bc5cde3b39c1f958b87c9296002ae76d142 (diff)
Hopefully removed all layer bugs
-rwxr-xr-xextract.sh5
-rw-r--r--src/pptdb.c54
2 files changed, 18 insertions, 41 deletions
diff --git a/extract.sh b/extract.sh
index b36ae02..42b2849 100755
--- a/extract.sh
+++ b/extract.sh
@@ -42,10 +42,13 @@ process() {
mv "data/shuf-$size.csv" "data/training-$size.csv"
echo -en "Done.\n\tCompressing data... "
if [ -f "data/training-$size.csv.gz" ]; then
- rm "data/training-$size.csv.gz"
+ rm "data/training-$size.csv.gz"
fi
gzip "data/training-$size.csv"
echo "Done, available in data/training-$size.csv.gz"
+ # mv "data/training-$size.csv" "data/validation-$size.csv"
+ # gzip "data/validation-$size.csv"
+ # echo "Done, available in data/validation-$size.csv.gz"
}
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) {