diff options
| author | tslil <tslil@posteo.de> | 2021-01-14 13:00:18 -0500 |
|---|---|---|
| committer | tslil <tslil@posteo.de> | 2026-08-28 19:37:41 +0100 |
| commit | 2a7b485265997d62625dc0ee5d8e91ede1c5f99f (patch) | |
| tree | e15e8e46743e8ce8bbaa0271834abbca82a784f1 /include/ct1986.c | |
| parent | b75526290b97e26d3fc3bbefef79f50a7febfe7d (diff) | |
So after a small tweak, it actually plays well!
Diffstat (limited to 'include/ct1986.c')
| -rw-r--r-- | include/ct1986.c | 10 |
1 files changed, 6 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); } |
