diff options
| author | tslil clingman <tslil@posteo.de> | 2021-01-21 01:18:01 -0500 |
|---|---|---|
| committer | tslil <tslil@posteo.de> | 2026-08-28 19:37:41 +0100 |
| commit | 19359dde885243e2359f7c560ae801efccee7294 (patch) | |
| tree | b27bc6f934e05b6494af8527b6b55bc554dc4c10 /src | |
| parent | 2ebcba8c471678942d0cbf496b79704df9bafff3 (diff) | |
| parent | 9fa3291044ff8d9f0f2b9c9a01cd210bf318ab74 (diff) | |
Merge branch 'negamax'
Diffstat (limited to 'src')
| -rw-r--r-- | src/ctaklm.c | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/src/ctaklm.c b/src/ctaklm.c index a7c299d..a1ca69d 100644 --- a/src/ctaklm.c +++ b/src/ctaklm.c @@ -3,7 +3,7 @@ #include <string.h> #include <tak.h> -#include <minimax_cnn1986.h> +#include <negamax_cnn1986.h> static const char *blk = "\033[41m", *wht = "\033[44m"; static const char *und = "\033[4m", *rst = "\033[0m"; @@ -151,9 +151,9 @@ print_info(void) { blk, black_count & 127, black_count >> 7, rst); } +static int human; static char *gamelog = 0; static uint8_t auto_board = 0xFF, auto_info = 0xFF; -static int human, search_depth; static void append_to_gamelog(const char *line, const uint8_t win_line) { @@ -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, search_depth); + printf("New %dx%d game! ct1986 at search depth %d.\n", + size, size, ct1986_search_depth); if (gamelog) gamelog = realloc(gamelog, sizeof(char)); else gamelog = malloc(sizeof(char)); gamelog[0] = 0; @@ -308,7 +308,7 @@ ct1986_display_progress(const uint8_t depth) { } static int -ct1986_turn(const uint8_t search_depth) { +ct1986_turn(void) { if (won == 0xFF) { // Prepare progress bar fputs("Computing [", stdout); @@ -317,7 +317,7 @@ ct1986_turn(const uint8_t search_depth) { fflush(stdout); // Run the minimax sum_depth = 0; num_check = 0; - float minimax = ct1986_generate(search_depth); + float minimax = ct1986_generate(); fputs("\033[1C ", stdout); // Failed to find a move? if (minimax <= -infty) { @@ -353,18 +353,19 @@ info, load, log, new, play (b|w), self-play, square <col><row>, <PTN>."); blk, eval, rst); } else { printf("White heruistic chance: %s%.2f%s\n", - wht, 100-eval, rst); + wht, -eval, rst); } } else if (!strcmp(line,"log")) { puts(gamelog); } else if (!strcmp(line,"new")) { new_game(5); } else if (!strcmp(line,"self-play")) { - while (ct1986_turn(search_depth) == 0); + while (ct1986_turn() == 0); } else if (!strncmp(line,"depth",5)) { if (strnlen(line,7) == 7 && line[6] >= '0' && line[6] <= '9') { - search_depth = line[6] - '0'; - printf("New search depth: %d.\n",search_depth); + ct1986_search_depth = line[6] - '0'; + printf("New search depth: %d.\n", + ct1986_search_depth); } else { puts("Usage: depth [0-9]."); } @@ -418,7 +419,7 @@ main(int argc, char **argv) { (void)(argv); human = 0; - search_depth = 1; + ct1986_search_depth = 3; new_game(5); char *line = NULL; @@ -446,7 +447,7 @@ main(int argc, char **argv) { if (read == -1) { playing = 0; } else { - ct1986_turn(search_depth); + ct1986_turn(); human = 0; } } |
