summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortslil <tslil@posteo.de>2021-01-14 00:33:42 -0500
committertslil <tslil@posteo.de>2026-08-28 19:37:41 +0100
commit718b116c05ef36215f6c6db79a4013f26a96b985 (patch)
treef4a92a705a1edde7088c07a18393dec4343bf4b5 /src
parentc78258adc03936fff70707ebf1942710a7b59416 (diff)
Trying alpha-beta pruning. There's a bug somewhere ...
Diffstat (limited to 'src')
-rw-r--r--src/ctaklm.c20
1 files changed, 12 insertions, 8 deletions
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);
+ }
}
}