From 9131e08817ae2f3bd58a8a0ba9f1e692ceb8604c Mon Sep 17 00:00:00 2001 From: tslil clingman Date: Tue, 26 Jan 2021 00:24:03 -0500 Subject: There is still a bug, it doesn't appear to be checking enough --- include/negamax.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'include/negamax.c') diff --git a/include/negamax.c b/include/negamax.c index 912705d..8b7345f 100644 --- a/include/negamax.c +++ b/include/negamax.c @@ -123,20 +123,22 @@ negamax(const uint8_t cur_depth, float alpha, float beta, action_take(node); // Compute the value of the node + float node_value; if (ply >= 2*board_size - 2 && (w = check_win()) < 0xFF) { - float winnings = -colour*infty; + node_value = -colour*infty; // Check win if far enough into the game - if (w == WIN_ROAD_BLACK || w == WIN_FLAT_BLACK) winnings = colour*infty; - else if (w == WIN_DRAW) winnings = 0; // Draw is fixed at neutral - value = fmax(value, winnings); + if (w == WIN_ROAD_BLACK || w == WIN_FLAT_BLACK) node_value = colour*infty; + else if (w == WIN_DRAW) node_value = 0; // Draw is fixed at neutral } else if (cur_depth > 1) { // If nobody won, or too early, recurse if not a leaf - value = fmax(value, -negamax(cur_depth - 1, -beta, -alpha, -colour)); + node_value = -negamax(cur_depth - 1, -beta, -alpha, -colour); } else { // Recursion would take us to a leaf, evaluate - value = fmax(value, colour*cnn1986_evaluate_black_win()); + node_value = colour * cnn1986_evaluate_black_win(); } + value = fmax(value, node_value); + action_undo(node); negamax_display_progress(cur_depth, list->length); -- cgit v1.3.1