If you generates the best move first you may play a better move in some cases.
1)It is obvious in case of only material evaluation and a program with only material evaluation that generates 1.e4 first is going to play 1.e4 that is better than a program that generates 1.a4 first.
2)In the case of not only material evaluation the possible difference is smaller but you still may have cases of 2 moves with exactly the same evaluation and it is better to generate the better move first in most of the cases.
3)Even when you play the same move if you generate the first move first you may save time later in ordering the moves.
I wonder if programmers tried testing changing the order of generating moves and if they found a difference in playing strength.
Looking at the code of stockfish I wonder what is the reason for oposite order of generating moves between captures and non captures.
It seems to me that it may be better to change the order of generating captures and start with pawn captures(and I also think that it may be better to start with generating castling moves in the second function because castling is the most logical move in case that it is possible)
I wonder if the programmers tested it and found no elo gain from it.
Here is the relevant code of stockfish.
Code: Select all
/// generate_captures() generates all pseudo-legal captures and queen
/// promotions. Returns a pointer to the end of the move list.
MoveStack* generate_captures(const Position& pos, MoveStack* mlist) {
assert(pos.is_ok());
assert(!pos.is_check());
Color us = pos.side_to_move();
Bitboard target = pos.pieces_of_color(opposite_color(us));
mlist = generate_piece_moves<QUEEN>(pos, mlist, us, target);
mlist = generate_piece_moves<ROOK>(pos, mlist, us, target);
mlist = generate_piece_moves<BISHOP>(pos, mlist, us, target);
mlist = generate_piece_moves<KNIGHT>(pos, mlist, us, target);
mlist = generate_piece_moves<PAWN, CAPTURE>(pos, mlist, us, target);
return generate_piece_moves<KING>(pos, mlist, us, target);
}
/// generate_noncaptures() generates all pseudo-legal non-captures and
/// underpromotions. Returns a pointer to the end of the move list.
MoveStack* generate_noncaptures(const Position& pos, MoveStack* mlist) {
assert(pos.is_ok());
assert(!pos.is_check());
Color us = pos.side_to_move();
Bitboard target = pos.empty_squares();
mlist = generate_piece_moves<PAWN, NON_CAPTURE>(pos, mlist, us, target);
mlist = generate_piece_moves<KNIGHT>(pos, mlist, us, target);
mlist = generate_piece_moves<BISHOP>(pos, mlist, us, target);
mlist = generate_piece_moves<ROOK>(pos, mlist, us, target);
mlist = generate_piece_moves<QUEEN>(pos, mlist, us, target);
mlist = generate_piece_moves<KING>(pos, mlist, us, target);
mlist = generate_castle_moves<KING_SIDE>(pos, mlist);
return generate_castle_moves<QUEEN_SIDE>(pos, mlist);
}