aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortslil <tslil@posteo.de>2021-01-13 16:39:16 -0500
committertslil <tslil@posteo.de>2026-08-28 19:37:41 +0100
commit2ef0078ba2afd99c4fc2673497f3d3a39119cf5d (patch)
tree3f3c791ee9b0136270f6cae2de3d96fce18e6a5c /src
parentaff5fe7f343194366beeda700a2f4a383e40fa73 (diff)
Trying minimax
Diffstat (limited to 'src')
-rw-r--r--src/ctaklm.c23
-rw-r--r--src/pptdb.c16
2 files changed, 25 insertions, 14 deletions
diff --git a/src/ctaklm.c b/src/ctaklm.c
index aafc0c3..4060911 100644
--- a/src/ctaklm.c
+++ b/src/ctaklm.c
@@ -4,7 +4,7 @@
#include <linenoise.h>
#include <tak.h>
-#include <ct1975.h>
+#include <ct1986.h>
const char *blk = "\033[41m", *wht = "\033[44m";
const char *rev = "\033[7m", *und = "\033[4m", *rst = "\033[0m";
@@ -154,7 +154,7 @@ print_info(void) {
wht,white_count >> 7,rst,
blk,black_count >> 7,rst);
printf("Valuation: %s%.6f%s\n",
- blk, ct1975_evaluate_black_win(), rst);
+ blk, ct1986_evaluate_black_win(), rst);
}
char *gamelog = 0;
@@ -300,7 +300,12 @@ load_ptn(const char* fn) {
}
static void
-dot(void) { putchar('.'); }
+dot(const uint8_t depth) {
+ if (depth == 0) {
+ putchar('#');
+ fflush(stdout);
+ }
+}
int
main(int argc, char **argv) {
@@ -308,6 +313,8 @@ main(int argc, char **argv) {
(void)(argv);
new_game(5);
+ ct1986_display_progress = &dot;
+
char *line;
while((line = linenoise("ctaklm> ")) != NULL) {
if (!strncmp(line,"help",5)) {
@@ -318,7 +325,7 @@ main(int argc, char **argv) {
} else if (!strncmp(line,"info",5)) {
print_info();
} else if (!strncmp(line,"eval",5)) {
- printf("Valuation: %.6f\n", ct1975_evaluate_black_win());
+ printf("Valuation: %.6f\n", ct1986_evaluate_black_win());
} else if (!strncmp(line,"log",3)) {
puts(gamelog);
} else if (!strncmp(line,"load",4)) {
@@ -359,11 +366,11 @@ main(int argc, char **argv) {
int r = handle_turn(line);
if (r == EXIT_SUCCESS && won == 0xFF) {
fputs("Thinking [", stdout);
- ct1975_generate_ptn(&dot);
+ float minimax = ct1986_minimax(0, 2, 0);
printf("] Result: %s (%.3f)\n",
- ct1975_ptn,
- ct1975_optimal*100.0);
- handle_turn(ct1975_ptn);
+ ct1986_ptn,
+ minimax*100.0);
+ handle_turn(ct1986_ptn);
}
}
diff --git a/src/pptdb.c b/src/pptdb.c
index 266d846..a67be1d 100644
--- a/src/pptdb.c
+++ b/src/pptdb.c
@@ -4,9 +4,9 @@
#include <tak.h>
-float max_flats;
+int generate;
uint64_t heights[16];
-int outcome_black, generate;
+float max_flats, outcome_black;
FILE *training_fh = NULL;
const int max_depth = 8;
@@ -105,9 +105,13 @@ parse_line(const char *pt, const ssize_t read) {
}
}
// Generate training data, not too early in the game
- if (generate && current_colour == C_BLACK && ply + 5 > total_plies) {
+ if (generate && ply + 5 > total_plies) {
write_input();
- fprintf(training_fh,"%d\n", outcome_black);
+ if (ply >= total_plies) {
+ if (outcome_black > 0.5) outcome_black = 1.0;
+ else outcome_black = 0.0;
+ }
+ fprintf(training_fh,"%.2f\n", outcome_black);
}
// Parse next action
while (idx<read && pt[idx++]!=',');
@@ -160,8 +164,8 @@ main(int argc, char **argv) {
// Reset everything
reset_state(size);
// Store the outcome of this game. Black win = 1
- if (line[read-4] == '0') outcome_black = 1;
- else outcome_black = 0;
+ if (line[read-4] == '0') outcome_black = 0.99;
+ else outcome_black = 0.01;
// Parse the line
r = parse_line(line,read-4);
// Adjust counts if we're not generating training data