MCPcopy Create free account
hub / github.com/dhbloo/rapfi / evaluate

Function evaluate

Rapfi/eval/eval.cpp:96–116  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

94/// @note Board must have at least one stone placed (`ply() > 0`).
95template <Rule R>
96Value 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
118template Value evaluate<FREESTYLE>(const Board &, Value, Value);
119template Value evaluate<STANDARD>(const Board &, Value, Value);

Callers 3

traceSearchFunction · 0.85
searchMethod · 0.85
TuneEntryMethod · 0.85

Calls 7

evaluateBasicFunction · 0.85
classicalEvalMarginFunction · 0.85
computeEvaluatorValueFunction · 0.85
plyMethod · 0.80
evaluatorMethod · 0.80
sideToMoveMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected