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

scan_for_easy_move: we don't need a loop here

Moves are already sorted, so just consider the best
and the second one.

Some trailing whitespace remove noise crept in due
to my editor removes it before to save.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
Marco Costalba 2008-09-03 23:33:49 +02:00
parent 9ec12da028
commit bd3fd6501b

View file

@ -1690,11 +1690,30 @@ namespace {
Move RootMoveList::scan_for_easy_move() const {
Value bestMoveValue = this->get_move_score(0);
for(int i = 1; i < this->move_count(); i++)
if(this->get_move_score(i) >= bestMoveValue - EasyMoveMargin)
assert(count);
if (count == 1)
return get_move(0);
// moves are sorted so just consider the best and the second one
if (get_move_score(0) > get_move_score(1) + EasyMoveMargin)
return get_move(0);
return MOVE_NONE;
return this->get_move(0);
}
// RootMoveList::compare_root_moves() is the comparison function used by
// RootMoveList::sort when sorting the moves. A move m1 is considered to
// be better than a move m2 if it has a higher score, or if the moves have
// equal score but m1 has the higher node count.
bool RootMoveList::compare_root_moves(const RootMove &rm1,
const RootMove &rm2) {
if (rm1.score != rm2.score)
return (rm1.score < rm2.score);
return rm1.nodes <= rm2.nodes;
}
@ -1727,21 +1746,6 @@ namespace {
}
// RootMoveList::compare_root_moves() is the comparison function used by
// RootMoveList::sort when sorting the moves. A move m1 is considered to
// be better than a move m2 if it has a higher score, or if the moves have
// equal score but m1 has the higher node count.
bool RootMoveList::compare_root_moves(const RootMove &rm1,
const RootMove &rm2) {
if (rm1.score != rm2.score)
return (rm1.score < rm2.score);
return rm1.nodes <= rm2.nodes;
}
// init_search_stack() initializes a search stack at the beginning of a
// new search from the root.