aboutsummaryrefslogtreecommitdiff
path: root/src/ctaklm.c
diff options
context:
space:
mode:
authortslil clingman <tslil@posteo.de>2021-01-20 15:38:03 -0500
committertslil <tslil@posteo.de>2026-08-28 19:37:41 +0100
commitb15185054c042153d0cf1b71ceb5c48dd4d18a13 (patch)
treefef6a3a93ba47a38f55806daaa23f380ad21af96 /src/ctaklm.c
parent47519b4428c6faecd6e51b2809095f53bd3a0b81 (diff)
Can't stop half-way through turn
Diffstat (limited to 'src/ctaklm.c')
-rw-r--r--src/ctaklm.c47
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;