aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortslil <tslil@posteo.de>2021-02-11 21:04:42 -0500
committertslil <tslil@posteo.de>2026-08-28 19:37:41 +0100
commit00a04c2929bdc8f8f4bf7d5d8cf413ebfb3cd006 (patch)
tree674e3336175b65e8ab9aa132ad1ea7adc124a121
parent890eb8d7f4a8c46eae18283ca5ac9c61fd41ed97 (diff)
Don't generate header for training data + tweaks
For some reason it would seem that moving flats to a lower value and increasing the proximity between caps and top flats improves acquisition. Still not great, but every bit counts.
-rwxr-xr-xresources/extract.sh13
-rw-r--r--src/pptdb.c17
2 files changed, 9 insertions, 21 deletions
diff --git a/resources/extract.sh b/resources/extract.sh
index b413d46..0d92ad4 100755
--- a/resources/extract.sh
+++ b/resources/extract.sh
@@ -44,18 +44,15 @@ process() {
./pptdb "$size" "data/good-playtak-$size" generate
echo -en "\tChoosing $num_games of $(wc -l data/training-$size.csv | cut -d\ -f1) samples... "
- head -n 1 "data/training-$size.csv" > "data/shuf-$size.csv"
- tail -n+2 "data/training-$size.csv" > "data/tmp"
- shuf -n $num_games "data/tmp" >> "data/shuf-$size.csv"
- rm data/tmp
+ shuf -n $num_games "data/training-$size.csv" > "data/shuf-$size.csv"
echo -en "Done.\n\tCompressing data... "
mv "data/shuf-$size.csv" "data/$fn-$size.csv"
- if [ -f "data/$fn-$size.csv.gz" ]; then
- rm "data/$fn-$size.csv.gz"
+ if [ -f "data/$fn-$size.csv.zst" ]; then
+ rm "data/$fn-$size.csv.zst"
fi
- gzip "data/$fn-$size.csv"
- echo "Done, available in data/$fn-$size.csv.gz"
+ zstd --rm -13 "data/$fn-$size.csv"
+ echo "Done, available in data/$fn-$size.csv.zst"
}
if [ ! -d data ]; then
diff --git a/src/pptdb.c b/src/pptdb.c
index 286678d..8684c47 100644
--- a/src/pptdb.c
+++ b/src/pptdb.c
@@ -53,18 +53,18 @@ write_input(const int dx, const int dy, const uint8_t swap) {
val = 0;
if (COUNT_AT(k)>depth) {
if (depth == 0) {
- // Top layer of stacks is handled differently to indicate
+ // 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;
+ val = (colours[k] & 1) ? +0.75 : -0.75;
}
} else {
// Layers underneath
- val = (colours[k] & (1<<depth)) ? +0.50 : -0.50;
+ val = (colours[k] & (1<<depth)) ? +0.75 : -0.75;
}
}
fprintf(training_fh,"%.2f,", val);
@@ -136,7 +136,7 @@ parse_line(const char *pt, const ssize_t read) {
}
// Generate training data, not too early in the game, all
// orientations
- if (generate && ply + 2 >= total_plies) {
+ if (generate && ply + 3 >= total_plies) {
#define RANDPM1 ((rand()&1)?-1:+1)
write_input(RANDPM1, RANDPM1, rand()&1);
}
@@ -181,15 +181,6 @@ int main(int argc, char **argv) {
snprintf(td_fn, 64, "data/training-%d.csv",size);
training_fh = fopen(td_fn, "w");
if (training_fh == NULL) exit(EXIT_FAILURE);
-
- // Write header
- fputs("\"White flats\",\"Black flats\",",training_fh);
- for (int depth = 0; depth < max_depth; depth++) {
- for (int k = 0; k < size*size; k++) {
- fprintf(training_fh,"\"Stack %d %d\",",depth,k);
- }
- }
- fputs("\"Outcome\"\n",training_fh);
} else generate=0;
while ((read = getline(&line, &len, playtak_fh)) != -1) {