diff options
| author | tslil clingman <tslil@posteo.de> | 2021-01-20 15:38:03 -0500 |
|---|---|---|
| committer | tslil <tslil@posteo.de> | 2026-08-28 19:37:41 +0100 |
| commit | b15185054c042153d0cf1b71ceb5c48dd4d18a13 (patch) | |
| tree | fef6a3a93ba47a38f55806daaa23f380ad21af96 | |
| parent | 47519b4428c6faecd6e51b2809095f53bd3a0b81 (diff) | |
Can't stop half-way through turn
| -rw-r--r-- | include/minimax_cnn1986.c | 2 | ||||
| -rw-r--r-- | src/ct1986.c | 2 | ||||
| -rw-r--r-- | src/ctaklm.c | 47 |
3 files changed, 27 insertions, 24 deletions
diff --git a/include/minimax_cnn1986.c b/include/minimax_cnn1986.c index d13195d..7363b23 100644 --- a/include/minimax_cnn1986.c +++ b/include/minimax_cnn1986.c @@ -384,5 +384,5 @@ ct1986_minimax(const uint8_t cur_depth, const uint8_t max_depth, inline float ct1986_generate(const uint8_t max_depth) { - return ct1986_minimax(0, max_depth, (ply & 1) ? 0 : 1, -infty, infty); + return ct1986_minimax(0, 1+2*max_depth, (ply & 1) ? 0 : 1, -infty, infty); } diff --git a/src/ct1986.c b/src/ct1986.c index b265b57..2e57ea6 100644 --- a/src/ct1986.c +++ b/src/ct1986.c @@ -167,7 +167,7 @@ main(int argc, char **argv) { if (lcd == NULL) return EXIT_FAILURE; human = 0; - search_depth = 3; + search_depth = 1; new_game(5); char *line = NULL; diff --git a/src/ctaklm.c b/src/ctaklm.c index eb2a788..24613e9 100644 --- a/src/ctaklm.c +++ b/src/ctaklm.c @@ -309,28 +309,31 @@ ct1986_display_progress(const uint8_t depth) { static int ct1986_turn(const uint8_t search_depth) { - // Prepare progress bar - fputs("Computing [", stdout); - for (int k = 0; k < board_size * board_size; k++) putchar(' '); - fputs("]\033[26D",stdout); - fflush(stdout); - // Run the minimax - sum_depth = 0; num_check = 0; - float minimax = ct1986_generate(search_depth); - fputs("\033[1C ", stdout); - // Failed to find a move? - if ((minimax <= -infty && (ply & 1) == 1) - ||(minimax >= infty && (ply & 1) == 0)) { - puts("Opponent concedes!"); - return EXIT_FAILURE; + if (won == 0xFF) { + // Prepare progress bar + fputs("Computing [", stdout); + for (int k = 0; k < board_size * board_size; k++) putchar(' '); + fputs("]\033[26D",stdout); + fflush(stdout); + // Run the minimax + sum_depth = 0; num_check = 0; + float minimax = ct1986_generate(search_depth); + fputs("\033[1C ", stdout); + // Failed to find a move? + if (minimax <= -infty) { + puts("Opponent concedes!"); + return EXIT_FAILURE; + } else { + printf("Result: %s (%.2f, %.1e, %.2f)\n", + ct1986_ptn, + minimax*100.0, + num_check, + sum_depth/num_check); + handle_turn(ct1986_ptn); + return EXIT_SUCCESS; + } } else { - printf("Result: %s (%.2f, %.1e, %.2f)\n", - ct1986_ptn, - minimax*100.0, - num_check, - sum_depth/num_check); - handle_turn(ct1986_ptn); - return EXIT_SUCCESS; + return EXIT_FAILURE; } } @@ -415,7 +418,7 @@ main(int argc, char **argv) { (void)(argv); human = 0; - search_depth = 3; + search_depth = 1; new_game(5); char *line = NULL; |
