ExactSolution * game_position_mab_solve (const GamePositionX *const root, const endgame_solver_env_t *const env, const bool alpha_beta_pruning) { g_assert(root); g_assert(env); GameTreeStack *stack = game_tree_stack_new(); game_tree_stack_init(root, stack); LogEnv *const log_env = game_tree_log_init(env->log_file); if (log_env->log_is_on) { game_tree_log_open_h(log_env); stack->hash_is_on = true; } ExactSolution *result = exact_solution_new(); exact_solution_set_solved_game_position_x(result, root); game_position_solve_impl(result, stack, log_env, alpha_beta_pruning); result->pv[0] = stack->nodes[1].best_move; result->outcome = stack->nodes[1].alpha; game_tree_stack_free(stack); game_tree_log_close(log_env); return result; }
/** * @brief Solves the game position returning a new exact solution pointer. * * @param [in] root the starting game position to be solved * @return a pointer to a new exact solution structure */ ExactSolution * game_position_rab_solve (const GamePosition * const root) { ExactSolution *result; SearchNode *sn; game_tree_stack_init(); result = exact_solution_new(); result->solved_game_position = game_position_clone(root); sn = game_position_solve_impl(result, result->solved_game_position); result->principal_variation[0] = sn->move; result->outcome = sn->value; sn = search_node_free(sn); return result; }