summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authortslil <tslil@posteo.de>2021-01-14 13:00:18 -0500
committertslil <tslil@posteo.de>2026-08-28 19:37:41 +0100
commit2a7b485265997d62625dc0ee5d8e91ede1c5f99f (patch)
treee15e8e46743e8ce8bbaa0271834abbca82a784f1 /include
parentb75526290b97e26d3fc3bbefef79f50a7febfe7d (diff)
So after a small tweak, it actually plays well!
Diffstat (limited to 'include')
-rw-r--r--include/ct1986.c10
-rw-r--r--include/ct1986.h1
2 files changed, 7 insertions, 4 deletions
diff --git a/include/ct1986.c b/include/ct1986.c
index 706640e..8378f8c 100644
--- a/include/ct1986.c
+++ b/include/ct1986.c
@@ -4,6 +4,7 @@
// Globals
// ===================================================================
+const float infty = 3.0;
char ct1986_ptn[9];
void (*ct1986_display_progress)(const uint8_t);
@@ -121,16 +122,17 @@ previous_ply(void) {
if ((min == 0) && (w == WIN_ROAD_BLACK \
|| w == WIN_FLAT_BLACK \
|| w == WIN_DRAGON)) { \
- this = +3; \
+ this = infty; \
} else if ((min > 0) \
&& (w == WIN_ROAD_WHITE \
|| w == WIN_FLAT_WHITE \
|| w == WIN_DRAGON)) { \
- this = -3; \
+ this = -infty; \
} /* Otherwise decide what to do based on our depth */ \
} else if (cur_depth == max_depth) { \
/* We're at the bottom, evaluate */ \
this = ct1986_evaluate_black_win(); \
+ if (min == 0) this = this - 1.0;\
} else { \
/* We're not at the bottom, recurse first */ \
next_ply(); \
@@ -160,7 +162,7 @@ ct1986_minimax(const uint8_t cur_depth, const uint8_t max_depth,
black_count_backup = black_count;
// 1.0 is a `certain' black win, -1.0 is a `certain' white win.
- float this = 0, optimal = (min) ? 2.0 : -2.0;
+ float this = 0, optimal = (min) ? infty : -infty;
// Step across the board
for (uint8_t row = 0; row < board_size; row++) {
@@ -269,5 +271,5 @@ ct1986_minimax(const uint8_t cur_depth, const uint8_t max_depth,
inline float
ct1986_generate(const uint8_t max_depth) {
- return ct1986_minimax(0, max_depth, 0, -10, 10);
+ return ct1986_minimax(0, max_depth, (ply & 1) ? 0 : 1, -infty, infty);
}
diff --git a/include/ct1986.h b/include/ct1986.h
index ef56c1f..3f2568d 100644
--- a/include/ct1986.h
+++ b/include/ct1986.h
@@ -2,6 +2,7 @@
#include "tak.h"
#include "weights.h"
+extern const float infty;
extern char ct1986_ptn[9];
extern void (*ct1986_display_progress)(const uint8_t);