1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-04-30 16:53:09 +00:00

MovePicker::find_best_index() never returns -1

So avoid checking for it.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
Marco Costalba 2009-01-25 13:36:59 +01:00
parent 3e6e57231e
commit c6d62b7da5

View file

@ -318,9 +318,11 @@ void MovePicker::score_qcaptures() {
int MovePicker::find_best_index() {
int bestScore = -10000000, bestIndex = -1;
assert(movesPicked < numOfMoves);
for (int i = movesPicked; i < numOfMoves; i++)
int bestIndex = movesPicked, bestScore = moves[movesPicked].score;
for (int i = movesPicked + 1; i < numOfMoves; i++)
if (moves[i].score > bestScore)
{
bestIndex = i;
@ -331,6 +333,8 @@ int MovePicker::find_best_index() {
int MovePicker::find_best_index(Bitboard* squares, int values[]) {
assert(movesPicked < numOfMoves);
int hs;
Move m;
Square to;
@ -378,6 +382,7 @@ Move MovePicker::pick_move_from_list() {
Move move;
switch (PhaseTable[phaseIndex]) {
case PH_GOOD_CAPTURES:
assert(!pos.is_check());
assert(movesPicked >= 0);
@ -385,9 +390,6 @@ Move MovePicker::pick_move_from_list() {
while (movesPicked < numOfMoves)
{
bestIndex = find_best_index();
if (bestIndex != -1) // Found a good capture
{
move = moves[bestIndex].move;
moves[bestIndex] = moves[movesPicked++];
if ( move != ttMove
@ -395,7 +397,6 @@ Move MovePicker::pick_move_from_list() {
&& pos.pl_move_is_legal(move, pinned))
return move;
}
}
break;
case PH_NONCAPTURES:
@ -409,9 +410,6 @@ Move MovePicker::pick_move_from_list() {
// been searched and it is not a PV node, we are probably failing low
// anyway, so we just pick the first move from the list.
bestIndex = (pvNode || movesPicked < 12) ? find_best_index() : movesPicked;
if (bestIndex != -1)
{
move = moves[bestIndex].move;
moves[bestIndex] = moves[movesPicked++];
if ( move != ttMove
@ -419,7 +417,6 @@ Move MovePicker::pick_move_from_list() {
&& pos.pl_move_is_legal(move, pinned))
return move;
}
}
break;
case PH_EVASIONS:
@ -429,14 +426,10 @@ Move MovePicker::pick_move_from_list() {
while (movesPicked < numOfMoves)
{
bestIndex = find_best_index();
if (bestIndex != -1)
{
move = moves[bestIndex].move;
moves[bestIndex] = moves[movesPicked++];
return move;
}
}
break;
case PH_BAD_CAPTURES:
@ -460,9 +453,6 @@ Move MovePicker::pick_move_from_list() {
while (movesPicked < numOfMoves)
{
bestIndex = (movesPicked < 4 ? find_best_index() : movesPicked);
if (bestIndex != -1)
{
move = moves[bestIndex].move;
moves[bestIndex] = moves[movesPicked++];
// Remember to change the line below if we decide to hash the qsearch!
@ -470,7 +460,6 @@ Move MovePicker::pick_move_from_list() {
if (/* move != ttMove && */ pos.pl_move_is_legal(move, pinned))
return move;
}
}
break;
case PH_QCHECKS: