2121using namespace bb ;
2222using namespace move ;
2323
24- int SearchData::getHistories (Move m, Color side, Move previous, Move followup, Square threatSquare) const {
24+ /* *
25+ * getHistories function retrieves the history scores of a given move, side, previous move, followup
26+ * move, and threat square. The function checks if the move is a capture move, and returns the
27+ * corresponding capture history score. If not, it computes the FMH, CMH and THREAT_HISTORY scores and
28+ * returns their average.
29+ *
30+ * @param m The move to retrieve history scores for
31+ * @param side The side the move is being made by
32+ * @param previous The previous move that was made in the search tree
33+ * @param followup The next move after the given move in the search tree
34+ * @param threatSquare The square that is being threatened by the given move
35+ * @return The history score for the given move
36+ */
37+ int SearchData::getHistories (Move m, Color side, Move previous, Move followup,
38+ Square threatSquare) const {
2539 if (isCapture (m)) {
26- return CAPTURE_HISTORY (this ,side,m);
40+ return CAPTURE_HISTORY (this , side, m);
2741 } else {
2842 auto fmh_value = (followup != 0 ? FMH (this , followup, side, m) : 0 );
2943 auto cmh_value = CMH (this , previous, side, m);
@@ -32,8 +46,14 @@ int SearchData::getHistories(Move m, Color side, Move previous, Move followup, S
3246 }
3347}
3448
35- /*
36- * Set killer
49+ /* *
50+ * setKiller sets a given move as the killer move for a given ply and color. It checks if the move is
51+ * not the same as the current killer move, and updates the killer move accordingly.
52+ *
53+ * @param move The move to set as the killer move
54+ * @param ply The ply in the search tree
55+ * @param color The color making the move
56+ * @return None
3757 */
3858void SearchData::setKiller (Move move, Depth ply, Color color) {
3959 if (!sameMove (move, KILLER1 (this , color, ply))) {
@@ -42,39 +62,61 @@ void SearchData::setKiller(Move move, Depth ply, Color color) {
4262 }
4363}
4464
45-
46- /*
47- * Is killer?
65+ /* *
66+ * isKiller checks if a given move is a killer move for a given ply and color.
67+ * It compares the given move to the first and second killer moves and returns 2 if it matches the
68+ * first, 1 if it matches the second, and 0 otherwise.
69+ *
70+ * @param move The move to check if it is a killer move
71+ * @param ply The ply in the search tree
72+ * @param color The color making the move
73+ * @return 2 if the move is the first killer move, 1 if the move is the second killer move, 0
74+ * otherwise
4875 */
4976int SearchData::isKiller (Move move, Depth ply, Color color) const {
5077 if (sameMove (move, KILLER1 (this , color, ply)))
5178 return 2 ;
5279 return sameMove (move, KILLER2 (this , color, ply));
5380}
54- /*
55- * Set historic eval
81+
82+ /* *
83+ * setHistoricEval sets the evaluation score for a given color and ply in the search tree.
84+ *
85+ * @param ev The evaluation score to set
86+ * @param color The color of the position being evaluated
87+ * @param ply The ply in the search tree
88+ * @return None
5689 */
5790void SearchData::setHistoricEval (Score ev, Color color, Depth ply) {
5891 EVAL_HISTORY (this , color, ply) = ev;
5992}
6093
61- /*
62- * Is improving
94+ /* *
95+ * isImproving checks if the evaluation score for a given color and ply in the search tree is
96+ * improving. It compares the given evaluation score to the previous evaluation score from 2 plies ago
97+ * and returns true if it is greater, false otherwise.
98+ *
99+ * @param ev The evaluation score to check for improvement
100+ * @param color The color of the position being evaluated
101+ * @param ply The ply in the search tree
102+ * @return true if the given evaluation score is greater than the previous evaluation score from 2
103+ * plies ago, false otherwise
63104 */
64105bool SearchData::isImproving (Score ev, Color color, Depth ply) const {
65106 if (ply >= 2 ) {
66- return (ev > EVAL_HISTORY (this , color, ply- 2 ));
107+ return (ev > EVAL_HISTORY (this , color, ply - 2 ));
67108 }
68109 return true ;
69110}
70111
112+ /* *
113+ * clear function sets all elements in the `th`, `captureHistory`, `cmh`, `fmh`, `killer` and
114+ * `maxImprovement` arrays to 0. This function is used to reset the search data for a new search
115+ * iteration.
116+ *
117+ * @return None
118+ */
71119void SearchData::clear () {
72- // std::memset(this->th, 0, 2*64*4096*4);
73- // std::memset(this->captureHistory, 0, 2*4096*4);
74- // std::memset(this->cmh, 0, 384*2*384*4);
75- // std::memset(this->fmh, 0, 384*2*384*4);
76- // std::memset(this->killer, 0, 2*257*2*4);
77- // std::memset(this->maxImprovement, 0, 64*64*4);
78120 std::memset (this ->th , 0 , sizeof (this ->th ));
79121 std::memset (this ->captureHistory , 0 , sizeof (this ->captureHistory ));
80122 std::memset (this ->cmh , 0 , sizeof (this ->cmh ));
0 commit comments