+ // Iterate until all positions are classified (30 cycles needed)
+ do {
+ repeat = false;
+
+ for (i = 0; i < IndexMax; i++)
+ if (bb[i] == RESULT_UNKNOWN)
+ {
+ pos.from_index(i);
+
+ bb[i] = (pos.sideToMove == WHITE) ? classify_wtm(pos, bb)
+ : classify_btm(pos, bb);
+ if (bb[i] != RESULT_UNKNOWN)
+ repeat = true;
+ }
+
+ } while (repeat);
+
+ // Compress result and map into supplied bitbase parameter
+ for (i = 0; i < 24576; i++)
+ {
+ b = 0;
+ for (j = 0; j < 8; j++)
+ if (bb[8*i+j] == RESULT_WIN || bb[8*i+j] == RESULT_LOSS)
+ b |= (1 << j);
+
+ bitbase[i] = (uint8_t)b;
+ }