-int MovePicker::find_best_index(Bitboard* squares, int values[]) {\r
-\r
- int hs;\r
- Move m;\r
- Square to;\r
- int bestScore = -10000000, bestIndex = -1;\r
-\r
- for (int i = movesPicked; i < numOfMoves; i++)\r
- {\r
- m = moves[i].move;\r
- to = move_to(m);\r
- \r
- if (!bit_is_set(*squares, to))\r
- {\r
- // Init at first use\r
- set_bit(squares, to);\r
- values[to] = 0;\r
- }\r
-\r
- hs = moves[i].score - values[to];\r
- if (hs > bestScore)\r
- {\r
- bestIndex = i;\r
- bestScore = hs;\r
- }\r
- }\r
-\r
- if (bestIndex != -1)\r
- {\r
- // Raise value of the picked square, so next attack\r
- // to the same square will get low priority.\r
- to = move_to(moves[bestIndex].move);\r
- values[to] += 0xB00;\r
- }\r
- return bestIndex;\r
+int MovePicker::find_best_index(Bitboard* squares, int values[]) {
+
+ assert(movesPicked < numOfMoves);
+
+ int hs;
+ Move m;
+ Square to;
+ int bestScore = -10000000, bestIndex = -1;
+
+ for (int i = movesPicked; i < numOfMoves; i++)
+ {
+ m = moves[i].move;
+ to = move_to(m);
+
+ if (!bit_is_set(*squares, to))
+ {
+ // Init at first use
+ set_bit(squares, to);
+ values[to] = 0;
+ }
+
+ hs = moves[i].score - values[to];
+ if (hs > bestScore)
+ {
+ bestIndex = i;
+ bestScore = hs;
+ }
+ }
+
+ if (bestIndex != -1)
+ {
+ // Raise value of the picked square, so next attack
+ // to the same square will get low priority.
+ to = move_to(moves[bestIndex].move);
+ values[to] += 0xB00;
+ }
+ return bestIndex;