From a77062ce3dc9a99ad0662010cc7eeb00dd5036a6 Mon Sep 17 00:00:00 2001 From: tslil clingman Date: Thu, 28 Jan 2021 21:30:30 -0500 Subject: Added license information! --- include/negamax.c | 53 +++++++++++++++++++++++++++++++++++------------------ 1 file changed, 35 insertions(+), 18 deletions(-) (limited to 'include/negamax.c') 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 . +*/ + #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); -- cgit v1.2.3