aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xresources/extract.sh8
-rw-r--r--src/pptdb.c18
2 files changed, 14 insertions, 12 deletions
diff --git a/resources/extract.sh b/resources/extract.sh
index fb2c30d..b413d46 100755
--- a/resources/extract.sh
+++ b/resources/extract.sh
@@ -2,7 +2,8 @@
db_file=games_anon.db
-chosen_players="AaaarghBot Tiltak_Bot TakticianBot"
+#chosen_players="AaaarghBot Tiltak_Bot TakticianBot"
+chosen_players=""
query() {
query="(size == $1) and (result != '1-0') and (result != '0-1') and (result != '0-0') and (result != '1/2-1/2')"
@@ -34,7 +35,10 @@ process() {
./pptdb "$size" "data/playtak-$size" > "data/check-$size"
tail -n22 "data/check-$size"
echo -ne "\tStripping overflows and illegal games... "
- grep -Fvxf "data/check-$size" "data/playtak-$size" > "data/good-playtak-$size"
+ grep -Fvxf "data/check-$size" "data/playtak-$size" > "data/good-playtak-$size-all"
+
+ shuf "data/good-playtak-$size-all" > "data/good-playtak-$size"
+ rm "data/good-playtak-$size-all"
echo -en "Done.\n\tGenerating training data... "
./pptdb "$size" "data/good-playtak-$size" generate
diff --git a/src/pptdb.c b/src/pptdb.c
index bb94987..286678d 100644
--- a/src/pptdb.c
+++ b/src/pptdb.c
@@ -24,10 +24,10 @@
#include <tak.h>
-float max_flats;
+int generate;
uint64_t heights[16];
FILE *training_fh = NULL;
-int generate, outcome_black;
+float max_flats, outcome_black;
const int max_depth = 6;
@@ -71,7 +71,7 @@ write_input(const int dx, const int dy, const uint8_t swap) {
}
}
}
- fprintf(training_fh,"%d\n", outcome_black);
+ fprintf(training_fh,"%.1f\n", outcome_black);
}
// Warning: performs _no_ checks on input whatsoever
@@ -136,11 +136,9 @@ parse_line(const char *pt, const ssize_t read) {
}
// Generate training data, not too early in the game, all
// orientations
- if (generate && ply + 4 >= total_plies) {
- write_input(-1, -1, 0); write_input(-1, -1, 1);
- write_input(-1, +1, 0); write_input(-1, +1, 1);
- write_input(+1, -1, 0); write_input(+1, -1, 1);
- write_input(+1, +1, 0); write_input(+1, +1, 1);
+ if (generate && ply + 2 >= total_plies) {
+#define RANDPM1 ((rand()&1)?-1:+1)
+ write_input(RANDPM1, RANDPM1, rand()&1);
}
// Parse next action
while (idx<read && pt[idx++]!=',');
@@ -198,8 +196,8 @@ int main(int argc, char **argv) {
// Reset everything
reset_state(size);
// Store the outcome of this game. Black win = 1
- if (line[read-4] == '0') outcome_black = 1;
- else outcome_black = -1;
+ if (line[read-4] == '0') outcome_black = 0.9;
+ else outcome_black = -0.9;
// Parse the line
r = parse_line(line,read-4);
// Adjust counts if we're not generating training data