aboutsummaryrefslogtreecommitdiff
path: root/src/ctaklm.c
diff options
context:
space:
mode:
authortslil <tslil@posteo.de>2021-01-12 19:32:40 -0500
committertslil <tslil@posteo.de>2026-08-28 19:37:41 +0100
commitf33d6fc3b09ade5b57b9438b54519e36e4261362 (patch)
treeb8b3fa9d45e73cd10121bac7faa05459c47df28c /src/ctaklm.c
parent91640db661fdcc04960d1f048ac60c2c4b2c5319 (diff)
Closing in!
Diffstat (limited to 'src/ctaklm.c')
-rw-r--r--src/ctaklm.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/ctaklm.c b/src/ctaklm.c
index 5df23c9..87fc30f 100644
--- a/src/ctaklm.c
+++ b/src/ctaklm.c
@@ -153,7 +153,7 @@ print_info(void) {
wht,white_count >> 7,rst,
blk,black_count >> 7,rst);
printf("Valuation: %s%.6f%s\n",
- blk, evaluate_black_win(), rst);
+ blk, ct1975_evaluate_black_win(), rst);
}
char *gamelog = 0;
@@ -203,7 +203,7 @@ handle_turn(char *line) {
case ACT_ILLEGAL: { puts("Illegal action."); return -1; break; }
case ACT_OVERFLOW: {
puts("Move would cause internal overflow, select another.");
- return -1;
+ return EXIT_FAILURE;
break;
}
// Game has ended
@@ -220,7 +220,7 @@ handle_turn(char *line) {
}
}
puts("Game over, enter `new' to play again.");
- if (! new_win) return -1;
+ if (! new_win) return EXIT_FAILURE;
break;
}
// Valid, append to game log
@@ -233,7 +233,7 @@ handle_turn(char *line) {
}
}
- return 0;
+ return EXIT_SUCCESS;
}
static void
@@ -298,6 +298,9 @@ load_ptn(const char* fn) {
return EXIT_SUCCESS;
}
+static void
+dot(void) { putchar('.'); }
+
int
main(int argc, char **argv) {
(void)(argc);
@@ -314,7 +317,7 @@ main(int argc, char **argv) {
} else if (!strncmp(line,"info",5)) {
print_info();
} else if (!strncmp(line,"eval",5)) {
- printf("Valuation: %.6f\n", evaluate_black_win());
+ printf("Valuation: %.6f\n", ct1975_evaluate_black_win());
} else if (!strncmp(line,"log",3)) {
puts(gamelog);
} else if (!strncmp(line,"load",4)) {
@@ -352,7 +355,15 @@ main(int argc, char **argv) {
puts("Usage: new [56].");
}
} else {
- handle_turn(line);
+ int r = handle_turn(line);
+ if (r == EXIT_SUCCESS) {
+ fputs("Thinking [", stdout);
+ ct1975_generate_ptn(&dot);
+ printf("] Result: %s (%.3f)\n",
+ ct1975_ptn,
+ ct1975_optimal*100.0);
+ handle_turn(ct1975_ptn);
+ }
}
free(line);