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:
parent
3e6e57231e
commit
c6d62b7da5
1 changed files with 28 additions and 39 deletions
|
@ -318,9 +318,11 @@ void MovePicker::score_qcaptures() {
|
||||||
|
|
||||||
int MovePicker::find_best_index() {
|
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)
|
if (moves[i].score > bestScore)
|
||||||
{
|
{
|
||||||
bestIndex = i;
|
bestIndex = i;
|
||||||
|
@ -331,6 +333,8 @@ int MovePicker::find_best_index() {
|
||||||
|
|
||||||
int MovePicker::find_best_index(Bitboard* squares, int values[]) {
|
int MovePicker::find_best_index(Bitboard* squares, int values[]) {
|
||||||
|
|
||||||
|
assert(movesPicked < numOfMoves);
|
||||||
|
|
||||||
int hs;
|
int hs;
|
||||||
Move m;
|
Move m;
|
||||||
Square to;
|
Square to;
|
||||||
|
@ -378,6 +382,7 @@ Move MovePicker::pick_move_from_list() {
|
||||||
Move move;
|
Move move;
|
||||||
|
|
||||||
switch (PhaseTable[phaseIndex]) {
|
switch (PhaseTable[phaseIndex]) {
|
||||||
|
|
||||||
case PH_GOOD_CAPTURES:
|
case PH_GOOD_CAPTURES:
|
||||||
assert(!pos.is_check());
|
assert(!pos.is_check());
|
||||||
assert(movesPicked >= 0);
|
assert(movesPicked >= 0);
|
||||||
|
@ -385,9 +390,6 @@ Move MovePicker::pick_move_from_list() {
|
||||||
while (movesPicked < numOfMoves)
|
while (movesPicked < numOfMoves)
|
||||||
{
|
{
|
||||||
bestIndex = find_best_index();
|
bestIndex = find_best_index();
|
||||||
|
|
||||||
if (bestIndex != -1) // Found a good capture
|
|
||||||
{
|
|
||||||
move = moves[bestIndex].move;
|
move = moves[bestIndex].move;
|
||||||
moves[bestIndex] = moves[movesPicked++];
|
moves[bestIndex] = moves[movesPicked++];
|
||||||
if ( move != ttMove
|
if ( move != ttMove
|
||||||
|
@ -395,7 +397,6 @@ Move MovePicker::pick_move_from_list() {
|
||||||
&& pos.pl_move_is_legal(move, pinned))
|
&& pos.pl_move_is_legal(move, pinned))
|
||||||
return move;
|
return move;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PH_NONCAPTURES:
|
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
|
// 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.
|
// anyway, so we just pick the first move from the list.
|
||||||
bestIndex = (pvNode || movesPicked < 12) ? find_best_index() : movesPicked;
|
bestIndex = (pvNode || movesPicked < 12) ? find_best_index() : movesPicked;
|
||||||
|
|
||||||
if (bestIndex != -1)
|
|
||||||
{
|
|
||||||
move = moves[bestIndex].move;
|
move = moves[bestIndex].move;
|
||||||
moves[bestIndex] = moves[movesPicked++];
|
moves[bestIndex] = moves[movesPicked++];
|
||||||
if ( move != ttMove
|
if ( move != ttMove
|
||||||
|
@ -419,7 +417,6 @@ Move MovePicker::pick_move_from_list() {
|
||||||
&& pos.pl_move_is_legal(move, pinned))
|
&& pos.pl_move_is_legal(move, pinned))
|
||||||
return move;
|
return move;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PH_EVASIONS:
|
case PH_EVASIONS:
|
||||||
|
@ -429,14 +426,10 @@ Move MovePicker::pick_move_from_list() {
|
||||||
while (movesPicked < numOfMoves)
|
while (movesPicked < numOfMoves)
|
||||||
{
|
{
|
||||||
bestIndex = find_best_index();
|
bestIndex = find_best_index();
|
||||||
|
|
||||||
if (bestIndex != -1)
|
|
||||||
{
|
|
||||||
move = moves[bestIndex].move;
|
move = moves[bestIndex].move;
|
||||||
moves[bestIndex] = moves[movesPicked++];
|
moves[bestIndex] = moves[movesPicked++];
|
||||||
return move;
|
return move;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PH_BAD_CAPTURES:
|
case PH_BAD_CAPTURES:
|
||||||
|
@ -460,9 +453,6 @@ Move MovePicker::pick_move_from_list() {
|
||||||
while (movesPicked < numOfMoves)
|
while (movesPicked < numOfMoves)
|
||||||
{
|
{
|
||||||
bestIndex = (movesPicked < 4 ? find_best_index() : movesPicked);
|
bestIndex = (movesPicked < 4 ? find_best_index() : movesPicked);
|
||||||
|
|
||||||
if (bestIndex != -1)
|
|
||||||
{
|
|
||||||
move = moves[bestIndex].move;
|
move = moves[bestIndex].move;
|
||||||
moves[bestIndex] = moves[movesPicked++];
|
moves[bestIndex] = moves[movesPicked++];
|
||||||
// Remember to change the line below if we decide to hash the qsearch!
|
// 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))
|
if (/* move != ttMove && */ pos.pl_move_is_legal(move, pinned))
|
||||||
return move;
|
return move;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PH_QCHECKS:
|
case PH_QCHECKS:
|
||||||
|
|
Loading…
Add table
Reference in a new issue