diff options
| author | tslil clingman <tslil@posteo.de> | 2021-01-30 16:47:48 -0500 |
|---|---|---|
| committer | tslil <tslil@posteo.de> | 2026-08-28 19:37:41 +0100 |
| commit | 84ad2e3c12cb505e3c5e3dd29d05edb529b82174 (patch) | |
| tree | 23c4ab5496bd9b82734eccb6d4f38e29cc8792ee /include/negamax.c | |
| parent | bda3a7edb76c9fe3dc21cbe5a0836829b705b407 (diff) | |
Try to squeeze out a little more performance
``Common wisdom'' dictates that placements are often better than stack
moves, so we bias the generated move list in this fashion. Seems to be
a little faster.
Diffstat (limited to 'include/negamax.c')
| -rw-r--r-- | include/negamax.c | 15 |
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; } |
