- // Iterate until all positions are classified (15 cycles needed)
- while (repeat)
- for (repeat = idx = 0; idx < IndexMax; idx++)
- if (db[idx] == UNKNOWN && db[idx].classify(db) != UNKNOWN)
- repeat = 1;
+ // Iterate through the positions until none of the unknown positions can be
+ // changed to either wins or draws (15 cycles needed).
+ while (std::accumulate(db.begin(), db.end(), false, [&](bool repeat, KPKPosition& pos)
+ { return (pos == UNKNOWN && pos.classify(db) != UNKNOWN) || repeat; }));