From e1c9a014420648b2799509016b4fc52dec19bc2d Mon Sep 17 00:00:00 2001 From: tslil clingman Date: Thu, 21 Jan 2021 01:31:22 -0500 Subject: Renaming --- src/ct1986.c | 25 ++++++++++++------------- src/ctaklm.c | 28 ++++++++++++++-------------- 2 files changed, 26 insertions(+), 27 deletions(-) (limited to 'src') diff --git a/src/ct1986.c b/src/ct1986.c index b930b13..49a1075 100644 --- a/src/ct1986.c +++ b/src/ct1986.c @@ -3,13 +3,13 @@ #include #include -#include +#include const char* esc = "\x1B[L"; FILE *lcd = NULL; static char *gamelog = 0; -static int human, search_depth; +static int human; static void write_line(const char *line) { @@ -93,11 +93,10 @@ new_game(uint8_t size) { gamelog[0] = 0; } -// Set up output function for ct1986 - +// Set up output function for negamax_cnn1986 static uint8_t perc; inline void -ct1986_display_progress(const uint8_t depth) { +negamax_cnn1986_display_progress(const uint8_t depth) { if (depth == 0) { perc++; // back four spaces and clear line, followed by perc% @@ -109,12 +108,12 @@ ct1986_display_progress(const uint8_t depth) { } static int -ct1986_turn(const uint8_t search_depth) { +negamax_cnn1986_turn() { // Prepare progress bar fputs("Computing: ", lcd); fflush(lcd); // Run the minimax perc = 0; - float minimax = ct1986_generate(search_depth); + float minimax = negamax_cnn1986_generate(); fputc('\n', lcd); fflush(lcd); // Failed to find a move? if (minimax <= -infty) { @@ -123,8 +122,8 @@ ct1986_turn(const uint8_t search_depth) { } else { fprintf(lcd, "%s: %s\n", (ply & 1) ? "Black" : "White", - ct1986_ptn); - handle_turn(ct1986_ptn); + negamax_cnn1986_ptn); + handle_turn(negamax_cnn1986_ptn); return EXIT_SUCCESS; } } @@ -140,8 +139,8 @@ input_is_not_turn(const char *line) { case 'l': { do_game_log(); break; } case 'n': { new_game(5); break; } case 'd': { - search_depth = line[1] - '0'; - fprintf(lcd, "Search depth: %d\n", search_depth); + negamax_cnn1986_search_depth = line[1] - '0'; + fprintf(lcd, "Search depth: %d\n", negamax_cnn1986_search_depth); fflush(lcd); break; } @@ -161,7 +160,7 @@ main(int argc, char **argv) { if (lcd == NULL) return EXIT_FAILURE; human = 0; - search_depth = 1; + negamax_cnn1986_search_depth = 3; new_game(5); fprintf(lcd, "%sB", esc); fflush(lcd); @@ -188,7 +187,7 @@ main(int argc, char **argv) { break; } } - ct1986_turn(search_depth); + negamax_cnn1986_turn(); human = 0; } diff --git a/src/ctaklm.c b/src/ctaklm.c index a1ca69d..da807c8 100644 --- a/src/ctaklm.c +++ b/src/ctaklm.c @@ -234,8 +234,8 @@ handle_turn(char *line) { static void new_game(uint8_t size) { reset_state(size); - printf("New %dx%d game! ct1986 at search depth %d.\n", - size, size, ct1986_search_depth); + printf("New %dx%d game! negamax_cnn1986 at search depth %d.\n", + size, size, negamax_cnn1986_search_depth); if (gamelog) gamelog = realloc(gamelog, sizeof(char)); else gamelog = malloc(sizeof(char)); gamelog[0] = 0; @@ -296,9 +296,9 @@ load_ptn(const char* fn) { static float sum_depth, num_check; -// Set up output function for ct1986 +// Set up output function for negamax_cnn1986 inline void -ct1986_display_progress(const uint8_t depth) { +negamax_cnn1986_display_progress(const uint8_t depth) { sum_depth += depth; num_check += 1; if (depth == 0) { @@ -308,7 +308,7 @@ ct1986_display_progress(const uint8_t depth) { } static int -ct1986_turn(void) { +negamax_cnn1986_turn(void) { if (won == 0xFF) { // Prepare progress bar fputs("Computing [", stdout); @@ -317,7 +317,7 @@ ct1986_turn(void) { fflush(stdout); // Run the minimax sum_depth = 0; num_check = 0; - float minimax = ct1986_generate(); + float minimax = negamax_cnn1986_generate(); fputs("\033[1C ", stdout); // Failed to find a move? if (minimax <= -infty) { @@ -325,11 +325,11 @@ ct1986_turn(void) { return EXIT_FAILURE; } else { printf("Result: %s (%.2f, %.1e, %.2f)\n", - ct1986_ptn, + negamax_cnn1986_ptn, minimax*100.0, num_check, sum_depth/num_check); - handle_turn(ct1986_ptn); + handle_turn(negamax_cnn1986_ptn); return EXIT_SUCCESS; } } else { @@ -347,7 +347,7 @@ info, load, log, new, play (b|w), self-play, square , ."); } else if (!strcmp(line,"info")) { print_info(); } else if (!strcmp(line,"eval")) { - float eval = ct1986_evaluate_black_win()*100; + float eval = cnn1986_evaluate_black_win()*100; if (ply & 1) { printf("Black heuristic chance: %s%.2f%s\n", blk, eval, rst); @@ -360,12 +360,12 @@ info, load, log, new, play (b|w), self-play, square , ."); } else if (!strcmp(line,"new")) { new_game(5); } else if (!strcmp(line,"self-play")) { - while (ct1986_turn() == 0); + while (negamax_cnn1986_turn() == 0); } else if (!strncmp(line,"depth",5)) { if (strnlen(line,7) == 7 && line[6] >= '0' && line[6] <= '9') { - ct1986_search_depth = line[6] - '0'; + negamax_cnn1986_search_depth = line[6] - '0'; printf("New search depth: %d.\n", - ct1986_search_depth); + negamax_cnn1986_search_depth); } else { puts("Usage: depth [0-9]."); } @@ -419,7 +419,7 @@ main(int argc, char **argv) { (void)(argv); human = 0; - ct1986_search_depth = 3; + negamax_cnn1986_search_depth = 3; new_game(5); char *line = NULL; @@ -447,7 +447,7 @@ main(int argc, char **argv) { if (read == -1) { playing = 0; } else { - ct1986_turn(); + negamax_cnn1986_turn(); human = 0; } } -- cgit v1.2.3