- entry = read_entry(idx);
-
- if (entry.key != key)
- break;
-
- score = entry.count;
-
- if (!findBestMove)
- {
- // Choose book move according to its score. If a move has a very
- // high score it has higher probability to be choosen than a move
- // with lower score. Note that first entry is always chosen.
- scoresSum += score;
- if (RKiss.rand<unsigned>() % scoresSum < score)
- bookMove = entry.move;
- }
- else if (score > bestScore)
- {
- bestScore = score;
+ scoresSum += entry.count;
+
+ // Choose book move according to its score. If a move has a very
+ // high score it has higher probability to be choosen than a move
+ // with lower score. Note that first entry is always chosen.
+ if ( RKiss.rand<unsigned>() % scoresSum < entry.count
+ || (findBest && entry.count > bestScore))