@@ -58,33 +58,23 @@ static int nnue_index(Board *board, int relksq, int colour, int sq) {
5858
5959int nnue_can_update (NNUEAccumulator * accum , Board * board , int colour ) {
6060
61- const NNUEAccumulator * start = board -> thread -> nnueStack ;
62-
63- // We can't recurse to update if we are at the start, or if our King has moved.
64- if ( (accum == start )
65- || (accum -> changes && accum -> deltas [0 ].piece == makePiece (KING , colour )))
66- return 0 ;
67-
68- // We can always update if our parent accum is accurate, without a King move
69- if ((accum - 1 )-> accurate [colour ])
70- return 1 ;
71-
72- // Otherwise, search back through the tree to find an accurate accum
73- while (accum != start ) {
74-
75- // We found it, so we can update the entire tree
76- if (accum -> accurate [colour ])
77- return 1 ;
61+ // Search back through the tree to find an accurate accum
62+ while (accum != board -> thread -> nnueStack ) {
7863
7964 // A King move prevents the entire tree from being updated
8065 if ( accum -> changes
8166 && accum -> deltas [0 ].piece == makePiece (KING , colour ))
82- return 0 ;
67+ return FALSE ;
8368
69+ // Step back, since the root can't be accurate
8470 accum = accum - 1 ;
71+
72+ // We found it, so we can update the entire tree
73+ if (accum -> accurate [colour ])
74+ return TRUE;
8575 }
8676
87- return 0 ;
77+ return FALSE ;
8878}
8979
9080void nnue_refresh_accumulator (NNUEAccumulator * accum , Board * board , int colour , int relsq ) {
0 commit comments