From 718b116c05ef36215f6c6db79a4013f26a96b985 Mon Sep 17 00:00:00 2001 From: tslil Date: Thu, 14 Jan 2021 00:33:42 -0500 Subject: Trying alpha-beta pruning. There's a bug somewhere ... --- src/ctaklm.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'src/ctaklm.c') diff --git a/src/ctaklm.c b/src/ctaklm.c index 7d6cedd..e7d9960 100644 --- a/src/ctaklm.c +++ b/src/ctaklm.c @@ -153,8 +153,6 @@ print_info(void) { printf("Caps remaining: %s%d%s, %s%d%s\n", wht,white_count >> 7,rst, blk,black_count >> 7,rst); - printf("Valuation: %s%.6f%s\n", - blk, ct1986_evaluate_black_win(), rst); } char *gamelog = 0; @@ -325,7 +323,8 @@ main(int argc, char **argv) { } else if (!strncmp(line,"info",5)) { print_info(); } else if (!strncmp(line,"eval",5)) { - printf("Valuation: %.6f\n", ct1986_evaluate_black_win()); + printf("Valuation: %s%.6f%s\n", + blk, ct1986_evaluate_black_win(), rst); } else if (!strncmp(line,"log",3)) { puts(gamelog); } else if (!strncmp(line,"load",4)) { @@ -369,12 +368,17 @@ main(int argc, char **argv) { fputs("Computing [", stdout); for (int k = 0; k < board_size * board_size; k++) putchar(' '); fputs("]\033[26D",stdout); + fflush(stdout); // Run the minimax - float minimax = ct1986_minimax(0, 2, 0); - printf("] Result: %s (%.3f)\n", - ct1986_ptn, - minimax*100.0); - handle_turn(ct1986_ptn); + float minimax = ct1986_minimax(0, 3, 0, -10, 10); + if (minimax < 0 || minimax > 1) { + puts("] Opponent concedes!"); + } else { + printf("] Result: %s (%.3f)\n", + ct1986_ptn, + minimax*100.0); + handle_turn(ct1986_ptn); + } } } -- cgit v1.3.1