From 8f15c1131342376ab3de2c6ce50d1ca5f20ec32a Mon Sep 17 00:00:00 2001 From: tslil clingman Date: Tue, 26 Jan 2021 23:54:46 -0500 Subject: I don't have the presence of mind to debug this right now --- include/negamax.c | 68 +++++++------------------------------------------------ 1 file changed, 8 insertions(+), 60 deletions(-) (limited to 'include/negamax.c') diff --git a/include/negamax.c b/include/negamax.c index 061b629..b51961d 100644 --- a/include/negamax.c +++ b/include/negamax.c @@ -8,73 +8,14 @@ const float infty = 3.0; char negamax_ptn[9]; uint8_t negamax_search_depth = 3; -static uint64_t *zobrist[15]; - // =================================================================== // Helpers // =================================================================== -static void -zobrist_free(void); - -static int -zobrist_init(void); - -static uint64_t -zobrist_compute(void); - static float negamax(const uint8_t cur_depth, float alpha, float beta, const float colour); -// =================================================================== -// Zobrist hashing -// =================================================================== - -static uint64_t -zobrist_compute(void) { - uint64_t hash = 0; - for (uint8_t l=0; l>= 1; - } - } - } - return hash; -} - -static int -zobrist_init(void) { - for (int k=0; k<15; k++) { - if (zobrist[k] != NULL) return EXIT_FAILURE; - } - - for (int j=0; j<15; j++) { - zobrist[j] = malloc(sizeof(uint64_t)*board_size*board_size*(2*3+1)); - for (int k=0; k= breaks search stability - if (entry != NULL && entry->depth == cur_depth) { + if (entry != NULL && entry->depth >= cur_depth) { if (entry->flag == TT_EXACT) { return entry->value; } else if (entry->flag == TT_LOWERBOUND && entry->value > alpha) { @@ -145,6 +86,13 @@ negamax(const uint8_t cur_depth, float alpha, float beta, for (action_node_t *node=list->head; node!=NULL; node=node->next) { action_take(node->action); + + { + if (zobrist_apply(node->action, hash) != zobrist_compute()) { + printf("! %s\n", (GET_TYPE(node->action)==A_PLACE)?"A_PLACE":"A_MOVE"); + } + } + // Compute the value of the node float node_value; if (ply >= 2*board_size - 2 && (w = check_win()) < 0xFF) { -- cgit v1.2.3