aboutsummaryrefslogtreecommitdiff
path: root/include/negamax.c
diff options
context:
space:
mode:
Diffstat (limited to 'include/negamax.c')
-rw-r--r--include/negamax.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/include/negamax.c b/include/negamax.c
index cdcfcf9..44deea9 100644
--- a/include/negamax.c
+++ b/include/negamax.c
@@ -30,7 +30,7 @@ uint8_t negamax_search_depth = 3;
// ===================================================================
static float negamax(const uint8_t cur_depth, float alpha, float beta,
- const float colour);
+ const float colour, const uint64_t hash);
// ===================================================================
// Exported functions
@@ -54,9 +54,8 @@ float negamax_generate(void) {
tt_init();
float result =
- negamax(negamax_search_depth,
- -safe_infty, safe_infty,
- (ply & 1) ? +1.0 : -1.0);
+ negamax(negamax_search_depth, -safe_infty, safe_infty,
+ (ply & 1) ? +1.0 : -1.0, zobrist_compute());
tt_free();
return result;
@@ -71,9 +70,8 @@ static enum TT_FLAG flag;
static enum WIN_TYPE w;
static float negamax(const uint8_t cur_depth, float alpha, float beta,
- const float colour) {
+ const float colour, const uint64_t hash) {
- uint64_t hash = zobrist_compute();
tt_entry_t *entry = tt_seek(hash);
// CAUTION: ≥ breaks search stability (vs =) on shallow depths
@@ -117,7 +115,8 @@ static float negamax(const uint8_t cur_depth, float alpha, float beta,
}
} else if (cur_depth > 1) {
// If nobody won, or too early and not leaf, recurse
- node_value = -negamax(cur_depth - 1, -beta, -alpha, -colour);
+ node_value = -negamax(cur_depth - 1, -beta, -alpha,
+ -colour, zobrist_compute());
} else {
node_value = colour * cnn1986_evaluate_black_win();
}
@@ -130,7 +129,7 @@ static float negamax(const uint8_t cur_depth, float alpha, float beta,
action_to_ptn(node->action, negamax_ptn);
}
- alpha = fmax(best_value, alpha);
+ if (best_value > alpha) alpha = best_value;
if (alpha >= beta) break;
}