diff options
| author | tslil clingman <tslil@posteo.de> | 2021-01-22 10:28:29 -0500 |
|---|---|---|
| committer | tslil <tslil@posteo.de> | 2026-08-28 19:37:41 +0100 |
| commit | 14edf3fa605d68601d154df57afb87ec2140cd03 (patch) | |
| tree | 7c84f2bc38b7238bb77c2308d56eac29f29cad7b /src/ctaklm.c | |
| parent | 8461e5ebea6e899eb0643f34ff03d7797d1441bf (diff) | |
Should now play out to the end
Diffstat (limited to 'src/ctaklm.c')
| -rw-r--r-- | src/ctaklm.c | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/src/ctaklm.c b/src/ctaklm.c index 95d8678..805e54d 100644 --- a/src/ctaklm.c +++ b/src/ctaklm.c @@ -294,7 +294,7 @@ load_ptn(const char* fn) { return EXIT_SUCCESS; } -static float sum_depth, num_check; +static float sum_depth, num_check, progress; // Set up output function for negamax_cnn1986 inline void @@ -302,7 +302,9 @@ negamax_cnn1986_display_progress(const uint8_t depth) { sum_depth += depth; num_check += 1; if (depth == 0) { - putchar('#'); + progress++; + printf("\x1B[1GComputing: %.0f%%", + (progress*100)/(board_size*board_size)); fflush(stdout); } } @@ -310,18 +312,15 @@ negamax_cnn1986_display_progress(const uint8_t depth) { static int negamax_cnn1986_turn(void) { if (won == 0xFF) { - // Prepare progress bar - fputs("Computing [", stdout); - for (int k = 0; k < board_size * board_size; k++) putchar(' '); - fputs("]\033[26D",stdout); + fputs("Computing: 0%", stdout); fflush(stdout); // Run the minimax - sum_depth = 0; num_check = 0; + sum_depth = 0; num_check = 0; progress = 0; float minimax = negamax_cnn1986_generate(); - fputs("\033[1C ", stdout); + putchar('\n'); // Failed to find a move? - if (minimax <= -infty) { - puts("Opponent concedes!"); + if (minimax < -infty) { + puts("Opponent failed to find a move!"); return EXIT_FAILURE; } else { printf("Result: %s (%.2f, %.1e, %.2f)\n", @@ -329,8 +328,7 @@ negamax_cnn1986_turn(void) { minimax*100.0, num_check, sum_depth/num_check); - handle_turn(negamax_cnn1986_ptn); - return EXIT_SUCCESS; + return handle_turn(negamax_cnn1986_ptn); } } else { return EXIT_FAILURE; |
