aboutsummaryrefslogtreecommitdiff
path: root/include/negamax.c
diff options
context:
space:
mode:
Diffstat (limited to 'include/negamax.c')
-rw-r--r--include/negamax.c14
1 files changed, 8 insertions, 6 deletions
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);