diff options
| author | tslil clingman <tslil@posteo.de> | 2021-01-28 21:30:30 -0500 |
|---|---|---|
| committer | tslil <tslil@posteo.de> | 2026-08-28 19:37:41 +0100 |
| commit | a77062ce3dc9a99ad0662010cc7eeb00dd5036a6 (patch) | |
| tree | 6936b60eb7a8221d38886d0db11953fe6ee56f23 /include/negamax.c | |
| parent | 473797d820b3b224ee1d370a50e4bcd01d09d48e (diff) | |
Added license information!
Diffstat (limited to 'include/negamax.c')
| -rw-r--r-- | include/negamax.c | 53 |
1 files changed, 35 insertions, 18 deletions
diff --git a/include/negamax.c b/include/negamax.c index 3db5867..cdcfcf9 100644 --- a/include/negamax.c +++ b/include/negamax.c @@ -1,7 +1,24 @@ +/* + This file is part of ctak. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Takwrap. If not, see <https://www.gnu.org/licenses/>. +*/ + #include "negamax.h" // =================================================================== -// Globals +// Variables // =================================================================== const float infty = 3.0; @@ -9,52 +26,52 @@ char negamax_ptn[9]; uint8_t negamax_search_depth = 3; // =================================================================== -// Helpers +// Helper declarations // =================================================================== -static float -negamax(const uint8_t cur_depth, float alpha, float beta, +static float negamax(const uint8_t cur_depth, float alpha, float beta, const float colour); // =================================================================== -// α-β negamax using the cnn1986 evaluation function and transposition -// tables using Zobrist hasing and a treap +// Exported functions // =================================================================== -void -negamax_init(const uint8_t new_board_size) { +void negamax_init(const uint8_t new_board_size) { board_size = new_board_size; action_list_init(); zobrist_init(); tt_init(); } -void -negamax_free(void) { +void negamax_free(void) { zobrist_free(); } -float -negamax_generate(void) { +float negamax_generate(void) { // We need to start with something outside of [-∞,∞] because those // values are wins const float safe_infty = infty + 1; tt_init(); - float result = negamax(negamax_search_depth, - -safe_infty, safe_infty, - (ply & 1) ? +1.0 : -1.0); + float result = + negamax(negamax_search_depth, + -safe_infty, safe_infty, + (ply & 1) ? +1.0 : -1.0); tt_free(); return result; } +// =================================================================== +// α-β negamax using the cnn1986 evaluation function and transposition +// tables using Zobrist hasing and a chaining hash table +// =================================================================== + 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) { +static float negamax(const uint8_t cur_depth, float alpha, float beta, + const float colour) { uint64_t hash = zobrist_compute(); tt_entry_t *entry = tt_seek(hash); |
