aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ct1986.c5
-rw-r--r--src/ctaklm.c22
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;