diff options
Diffstat (limited to 'src/ctaklm.c')
| -rw-r--r-- | src/ctaklm.c | 39 |
1 files changed, 18 insertions, 21 deletions
diff --git a/src/ctaklm.c b/src/ctaklm.c index aaeddde..59e0e2e 100644 --- a/src/ctaklm.c +++ b/src/ctaklm.c @@ -3,7 +3,7 @@ #include <string.h> #include <tak.h> -#include <negamax_cnn1986.h> +#include <negamax.h> static const char *blk = "\033[41m", *wht = "\033[44m"; static const char *und = "\033[4m", *rst = "\033[0m"; @@ -234,8 +234,8 @@ handle_turn(char *line) { static void new_game(uint8_t size) { reset_state(size); - printf("New %dx%d game! negamax_cnn1986 at search depth %d.\n", - size, size, negamax_cnn1986_search_depth); + printf("New %dx%d game! negamax at search depth %d.\n", + size, size, negamax_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, progress; -// Set up output function for negamax_cnn1986 +// Set up output function for negamax inline void -negamax_cnn1986_display_progress(const uint8_t depth) { +negamax_display_progress(const uint8_t depth) { sum_depth += depth; num_check += 1; if (depth == 0) { @@ -310,13 +310,13 @@ negamax_cnn1986_display_progress(const uint8_t depth) { } static int -negamax_cnn1986_turn(void) { +negamax_turn(void) { if (won == 0xFF) { fputs("Computing: 0%", stdout); fflush(stdout); // Run the minimax sum_depth = 0; num_check = 0; progress = 0; - float minimax = negamax_cnn1986_generate(); + float minimax = negamax_generate(); printf(" [%d]\n", cnn1986_num_cached); // Failed to find a move? if (minimax < -infty) { @@ -324,11 +324,11 @@ negamax_cnn1986_turn(void) { return EXIT_FAILURE; } else { printf("Result: %s (%.2f, %.1e, %.2f)\n", - negamax_cnn1986_ptn, + negamax_ptn, minimax*100.0, num_check, sum_depth/num_check); - return handle_turn(negamax_cnn1986_ptn); + return handle_turn(negamax_ptn); } } else { return EXIT_FAILURE; @@ -358,12 +358,12 @@ info, load, log, new, play (b|w), self-play, square <col><row>, <PTN>."); } else if (!strcmp(line,"new")) { new_game(5); } else if (!strcmp(line,"self-play")) { - while (negamax_cnn1986_turn() == 0); + while (negamax_turn() == 0); } else if (!strncmp(line,"depth",5)) { if (strnlen(line,7) == 7 && line[6] >= '0' && line[6] <= '9') { - negamax_cnn1986_search_depth = line[6] - '0'; + negamax_search_depth = line[6] - '0'; printf("New search depth: %d.\n", - negamax_cnn1986_search_depth); + negamax_search_depth); } else { puts("Usage: depth [0-9]."); } @@ -418,17 +418,16 @@ main(int argc, char **argv) { /* * cnn1986_max_num_cached = 500; - * negamax_cnn1986_search_depth = 3; - * negamax_cnn1986_cache_threshold = 3; + * negamax_search_depth = 3; + * negamax_cache_threshold = 3; * new_game(5); */ // Test harness - negamax_cnn1986_cache_threshold = atoi(argv[1]); - cnn1986_max_num_cached = atoi(argv[2]); - negamax_cnn1986_search_depth = 4; + negamax_init_size(); + negamax_search_depth = 5; new_game(5); - for (int k=0; k<8; k++) negamax_cnn1986_turn(); + for (int k=0; k<8; k++) negamax_turn(); return 0; // Test harness @@ -456,12 +455,10 @@ main(int argc, char **argv) { } } if (playing) { - negamax_cnn1986_turn(); + negamax_turn(); human = 0; } } - cnn1986_cache_free(); - return EXIT_SUCCESS; } |
