From 14edf3fa605d68601d154df57afb87ec2140cd03 Mon Sep 17 00:00:00 2001 From: tslil clingman Date: Fri, 22 Jan 2021 10:28:29 -0500 Subject: Should now play out to the end --- src/ct1986.c | 5 ++--- src/ctaklm.c | 22 ++++++++++------------ 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/src/ct1986.c b/src/ct1986.c index 273fd98..40943db 100644 --- a/src/ct1986.c +++ b/src/ct1986.c @@ -102,7 +102,7 @@ negamax_cnn1986_turn() { perc = 0; float minimax = negamax_cnn1986_generate(); // Failed to find a move? - if (minimax <= -infty) { + if (minimax < -infty) { lcd_printf_line(L_SCROLL, "%s concedes!", (ply & 1) ? "Black" : "White"); return EXIT_FAILURE; @@ -110,8 +110,7 @@ negamax_cnn1986_turn() { lcd_printf_line(L_SCROLL, "%s: %s", (ply & 1) ? "Black" : "White", negamax_cnn1986_ptn); - handle_turn(negamax_cnn1986_ptn); - return EXIT_SUCCESS; + return handle_turn(negamax_cnn1986_ptn); } } 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; -- cgit v1.2.3