From 3db577276b055ff7c8a8ed22302e9333ca679c26 Mon Sep 17 00:00:00 2001 From: tslil clingman Date: Mon, 25 Jan 2021 00:14:31 -0500 Subject: Lots of bugfixes, mostly uint vs int. Still weirdness in game --- include/negamax.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'include/negamax.c') diff --git a/include/negamax.c b/include/negamax.c index 812f8f7..757a648 100644 --- a/include/negamax.c +++ b/include/negamax.c @@ -83,8 +83,8 @@ zobrist_free(void) { void negamax_init(const uint8_t new_board_size) { board_size = new_board_size; + action_list_init(); zobrist_init(); - action_list_init(board_size); } void @@ -115,26 +115,28 @@ negamax(const uint8_t cur_depth, float alpha, float beta, float value = -infty; action_list_t *action_list = action_list_generate(); + action_list_t *action = action_list; - for (action_list_t *action = action_list; - action != NULL; - action = action->next) { - + while (action != NULL) { negamax_display_progress(cur_depth); + action_take(action); if (cur_depth > 1) { - value = colour*cnn1986_evaluate_black_win(); - } else { - action_take(action); value = fmax(value, -negamax(cur_depth - 1, -beta, -alpha, -colour)); - action_undo(action); + } else { + value = fmax(value, colour*cnn1986_evaluate_black_win()); } + action_undo(action); + // alpha = fmax(alpha, value); if (value > alpha) { alpha = value; - action_to_ptn(action, negamax_ptn); + if (cur_depth == negamax_search_depth) + action_to_ptn(action, negamax_ptn); } if (alpha >= beta) break; + + action = action->next; } action_list_free(action_list); -- cgit v1.2.3