diff options
| author | tslil clingman <tslil@posteo.de> | 2021-01-25 00:14:31 -0500 |
|---|---|---|
| committer | tslil <tslil@posteo.de> | 2026-08-28 19:37:41 +0100 |
| commit | 3db577276b055ff7c8a8ed22302e9333ca679c26 (patch) | |
| tree | acfbb652c6d923835f08e29cea69f42c6cdb52e1 /include/negamax.c | |
| parent | d96ea8235a63bcb75e8b13286e84ee1b4168d127 (diff) | |
Lots of bugfixes, mostly uint vs int. Still weirdness in game
Diffstat (limited to 'include/negamax.c')
| -rw-r--r-- | include/negamax.c | 22 |
1 files changed, 12 insertions, 10 deletions
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); |
