diff options
| author | tslil <tslil@posteo.de> | 2021-01-12 16:48:41 -0500 |
|---|---|---|
| committer | tslil <tslil@posteo.de> | 2026-08-28 19:37:41 +0100 |
| commit | 3d1e8f16ac53aad322f2c681f5f3c25918c58602 (patch) | |
| tree | adb2819f03b34cf119e96d974ee5ae1cec877e06 /src | |
| parent | 4b4c3853c8ed0dab49e535db3dfd2a49a7dfea08 (diff) | |
Generate the correct format directly
Diffstat (limited to 'src')
| -rw-r--r-- | src/pptdb.c | 33 | ||||
| -rw-r--r-- | src/train5.py | 2 |
2 files changed, 8 insertions, 27 deletions
diff --git a/src/pptdb.c b/src/pptdb.c index 35aa325..7d8026d 100644 --- a/src/pptdb.c +++ b/src/pptdb.c @@ -6,7 +6,7 @@ float max_flats; uint64_t heights[16]; -int result, generate; +int outcome_black, generate; FILE *training_fh = NULL; const int max_depth = 8; @@ -54,9 +54,7 @@ parse_line(const char *pt, const ssize_t read) { for (idx=0;idx<read;idx++) { if (pt[idx]==',') total_plies++; } - - idx=0; - for(;;) { + for(idx=0;;) { if (pt[idx] == 'P') { // P [A-F][1-6] [CF]?, idx+=2; @@ -75,12 +73,6 @@ 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); - */ } else if (pt[idx] == 'M') { // M [A-F][1-6] [A-F][1-6]( [1-6])+, idx+=2; @@ -111,22 +103,11 @@ parse_line(const char *pt, const ssize_t read) { if (COUNT_AT(k)>1) heights[COUNT_AT(k)]+=1; } } - - /* - * 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"); - */ - // Generate training data, not too early in the game if (generate && current_colour == C_BLACK && ply > total_plies - 5) { write_input(); - fprintf(training_fh,"%d,%d\n", result, 1-result); + fprintf(training_fh,"%d\n", outcome_black); } // Parse next action while (idx<read && pt[idx++]!=','); @@ -172,15 +153,15 @@ main(int argc, char **argv) { fprintf(training_fh,"\"Stack %d %d\",",depth,k); } } - fputs("\"White win\",\"Black win\"\n",training_fh); + fputs("\"Outcome\"\n",training_fh); } else generate=0; while ((read = getline(&line, &len, playtak_fh)) != -1) { // Reset everything reset_state(size); - // Store the result of this game - if (line[read-4] == '0') result = 0; - else result = 1; + // Store the outcome of this game. Black win = 1 + if (line[read-4] == '0') outcome_black = 1; + else outcome_black = 0; // Parse the line r = parse_line(line,read-4); // Adjust counts if we're not generating training data diff --git a/src/train5.py b/src/train5.py index 214ad88..adb81a5 100644 --- a/src/train5.py +++ b/src/train5.py @@ -69,7 +69,7 @@ def load_data(size): training_outcome = training_data.iloc[:, -1:] val_fn = "validation-"+str(size)+".csv" - val_data = pd.read_csv(val_fn).tail(20000) + val_data = pd.read_csv(val_fn) #.tail(20000) val_stack_input = np.array(val_data.iloc[:, 2:-1]).reshape(shape, order='F') val_flats_input = np.array(val_data.iloc[:, 0:2]) val_input = [val_stack_input, val_flats_input] |
