aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortslil clingman <tslil@posteo.de>2021-01-21 01:16:20 -0500
committertslil <tslil@posteo.de>2026-08-28 19:37:41 +0100
commit9fa3291044ff8d9f0f2b9c9a01cd210bf318ab74 (patch)
treeb27bc6f934e05b6494af8527b6b55bc554dc4c10 /src
parent232013bda72120f69c1780c4af381884ca111ef4 (diff)
Many fixes, i think this is actually correct
Diffstat (limited to 'src')
-rw-r--r--src/ctaklm.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/src/ctaklm.c b/src/ctaklm.c
index 3392af4..a1ca69d 100644
--- a/src/ctaklm.c
+++ b/src/ctaklm.c
@@ -3,7 +3,7 @@
#include <string.h>
#include <tak.h>
-#include <minimax_cnn1986.h>
+#include <negamax_cnn1986.h>
static const char *blk = "\033[41m", *wht = "\033[44m";
static const char *und = "\033[4m", *rst = "\033[0m";
@@ -151,9 +151,9 @@ print_info(void) {
blk, black_count & 127, black_count >> 7, rst);
}
+static int human;
static char *gamelog = 0;
static uint8_t auto_board = 0xFF, auto_info = 0xFF;
-static int human, search_depth;
static void
append_to_gamelog(const char *line, const uint8_t win_line) {
@@ -235,7 +235,7 @@ static void
new_game(uint8_t size) {
reset_state(size);
printf("New %dx%d game! ct1986 at search depth %d.\n",
- size, size, search_depth);
+ size, size, ct1986_search_depth);
if (gamelog) gamelog = realloc(gamelog, sizeof(char));
else gamelog = malloc(sizeof(char));
gamelog[0] = 0;
@@ -308,7 +308,7 @@ ct1986_display_progress(const uint8_t depth) {
}
static int
-ct1986_turn(const uint8_t search_depth) {
+ct1986_turn(void) {
if (won == 0xFF) {
// Prepare progress bar
fputs("Computing [", stdout);
@@ -317,7 +317,7 @@ ct1986_turn(const uint8_t search_depth) {
fflush(stdout);
// Run the minimax
sum_depth = 0; num_check = 0;
- float minimax = ct1986_generate(search_depth);
+ float minimax = ct1986_generate();
fputs("\033[1C ", stdout);
// Failed to find a move?
if (minimax <= -infty) {
@@ -347,24 +347,25 @@ info, load, log, new, play (b|w), self-play, square <col><row>, <PTN>.");
} else if (!strcmp(line,"info")) {
print_info();
} else if (!strcmp(line,"eval")) {
- float eval = ct1986_evaluate_win()*100;
+ float eval = ct1986_evaluate_black_win()*100;
if (ply & 1) {
printf("Black heuristic chance: %s%.2f%s\n",
blk, eval, rst);
} else {
printf("White heruistic chance: %s%.2f%s\n",
- wht, eval, rst);
+ wht, -eval, rst);
}
} else if (!strcmp(line,"log")) {
puts(gamelog);
} else if (!strcmp(line,"new")) {
new_game(5);
} else if (!strcmp(line,"self-play")) {
- while (ct1986_turn(search_depth) == 0);
+ while (ct1986_turn() == 0);
} else if (!strncmp(line,"depth",5)) {
if (strnlen(line,7) == 7 && line[6] >= '0' && line[6] <= '9') {
- search_depth = line[6] - '0';
- printf("New search depth: %d.\n",search_depth);
+ ct1986_search_depth = line[6] - '0';
+ printf("New search depth: %d.\n",
+ ct1986_search_depth);
} else {
puts("Usage: depth [0-9].");
}
@@ -418,7 +419,7 @@ main(int argc, char **argv) {
(void)(argv);
human = 0;
- search_depth = 3;
+ ct1986_search_depth = 3;
new_game(5);
char *line = NULL;
@@ -446,7 +447,7 @@ main(int argc, char **argv) {
if (read == -1) {
playing = 0;
} else {
- ct1986_turn(search_depth);
+ ct1986_turn();
human = 0;
}
}