diff options
| author | tslil clingman <tslil@posteo.de> | 2021-01-20 15:38:03 -0500 |
|---|---|---|
| committer | tslil <tslil@posteo.de> | 2021-01-20 15:38:03 -0500 |
| commit | 56ca7a12b278fb1e0ba77eb4959ab8c058b2503d (patch) | |
| tree | fef6a3a93ba47a38f55806daaa23f380ad21af96 /src/ctaklm.c | |
| parent | 1de581e669b6355a2427a07e3b6427a5c0247b35 (diff) | |
Can't stop half-way through turn
Diffstat (limited to 'src/ctaklm.c')
| -rw-r--r-- | src/ctaklm.c | 47 |
1 files changed, 25 insertions, 22 deletions
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; |
