| 94 | /// @note Board must have at least one stone placed (`ply() > 0`). |
| 95 | template <Rule R> |
| 96 | Value evaluate(const Board &board, Value alpha, Value beta) |
| 97 | { |
| 98 | assert(board.ply() > 0); |
| 99 | Color self = board.sideToMove(); |
| 100 | |
| 101 | const StateInfo &st0 = board.stateInfo(); |
| 102 | const StateInfo &st1 = board.stateInfo(1); |
| 103 | |
| 104 | Value basicEval = (evaluateBasic(st0, self) + evaluateBasic(st1, self)) / 2; |
| 105 | Value threatEval = evaluateThreat<R>(st0, self); |
| 106 | Value eval = std::clamp(basicEval + threatEval, VALUE_EVAL_MIN, VALUE_EVAL_MAX); |
| 107 | |
| 108 | if (board.evaluator()) { |
| 109 | // Use evaluator eval if classical eval are in alpha-beta window margin |
| 110 | int margin = classicalEvalMargin(eval); |
| 111 | if (eval >= alpha - margin && eval <= beta + margin) |
| 112 | return computeEvaluatorValue(board).value(); |
| 113 | } |
| 114 | |
| 115 | return eval; |
| 116 | } |
| 117 | |
| 118 | template Value evaluate<FREESTYLE>(const Board &, Value, Value); |
| 119 | template Value evaluate<STANDARD>(const Board &, Value, Value); |
no test coverage detected