mirror of
https://github.com/sockspls/badfish
synced 2025-07-11 19:49:14 +00:00
A bit of reformatting after previous series
And some documentation update. No functional change. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
parent
9884573561
commit
4c3a000211
6 changed files with 25 additions and 32 deletions
|
@ -304,16 +304,7 @@ MoveStack* generate<MV_EVASION>(const Position& pos, MoveStack* mlist) {
|
|||
}
|
||||
|
||||
|
||||
/// generate<MV_LEGAL / MV_PSEUDO_LEGAL> computes a complete list of legal
|
||||
/// or pseudo-legal moves in the current position.
|
||||
template<>
|
||||
MoveStack* generate<MV_PSEUDO_LEGAL>(const Position& pos, MoveStack* mlist) {
|
||||
|
||||
assert(pos.is_ok());
|
||||
|
||||
return pos.in_check() ? generate<MV_EVASION>(pos, mlist)
|
||||
: generate<MV_NON_EVASION>(pos, mlist);
|
||||
}
|
||||
/// generate<MV_LEGAL> computes a complete list of legal moves in the current position
|
||||
|
||||
template<>
|
||||
MoveStack* generate<MV_LEGAL>(const Position& pos, MoveStack* mlist) {
|
||||
|
@ -323,7 +314,8 @@ MoveStack* generate<MV_LEGAL>(const Position& pos, MoveStack* mlist) {
|
|||
MoveStack *last, *cur = mlist;
|
||||
Bitboard pinned = pos.pinned_pieces(pos.side_to_move());
|
||||
|
||||
last = generate<MV_PSEUDO_LEGAL>(pos, mlist);
|
||||
last = pos.in_check() ? generate<MV_EVASION>(pos, mlist)
|
||||
: generate<MV_NON_EVASION>(pos, mlist);
|
||||
|
||||
// Remove illegal moves from the list
|
||||
while (cur != last)
|
||||
|
|
|
@ -30,8 +30,7 @@ enum MoveType {
|
|||
MV_NON_CAPTURE_CHECK,
|
||||
MV_EVASION,
|
||||
MV_NON_EVASION,
|
||||
MV_LEGAL,
|
||||
MV_PSEUDO_LEGAL
|
||||
MV_LEGAL
|
||||
};
|
||||
|
||||
template<MoveType>
|
||||
|
|
|
@ -48,8 +48,7 @@ namespace {
|
|||
|
||||
bool MovePicker::isBadCapture() const { return phase == PH_BAD_CAPTURES; }
|
||||
|
||||
/// Constructor for the MovePicker class. Apart from the position for which
|
||||
/// it is asked to pick legal moves, MovePicker also wants some information
|
||||
/// Constructor for the MovePicker class. As arguments we pass information
|
||||
/// to help it to return the presumably good moves first, to decide which
|
||||
/// moves to return (in the quiescence search, for instance, we only want to
|
||||
/// search captures, promotions and some checks) and about how important good
|
||||
|
@ -251,7 +250,7 @@ void MovePicker::score_evasions() {
|
|||
}
|
||||
|
||||
/// MovePicker::get_next_move() is the most important method of the MovePicker
|
||||
/// class. It returns a new legal move every time it is called, until there
|
||||
/// class. It returns a new pseudo legal move every time it is called, until there
|
||||
/// are no more moves left. It picks the move with the biggest score from a list
|
||||
/// of generated moves taking care not to return the tt move if has already been
|
||||
/// searched previously. Note that this function is not thread safe so should be
|
||||
|
@ -286,7 +285,7 @@ Move MovePicker::get_next_move() {
|
|||
return move;
|
||||
|
||||
// Losing capture, move it to the tail of the array, note
|
||||
// that move has now been already checked for legality.
|
||||
// that move has now been already checked for pseudo legality.
|
||||
(--badCaptures)->move = move;
|
||||
badCaptures->score = seeValue;
|
||||
}
|
||||
|
@ -328,7 +327,7 @@ Move MovePicker::get_next_move() {
|
|||
|
||||
case PH_QCHECKS:
|
||||
move = (curMove++)->move;
|
||||
if ( move != ttMoves[0].move)
|
||||
if (move != ttMoves[0].move)
|
||||
return move;
|
||||
break;
|
||||
|
||||
|
|
|
@ -27,11 +27,11 @@
|
|||
|
||||
struct SearchStack;
|
||||
|
||||
/// MovePicker is a class which is used to pick one legal move at a time from
|
||||
/// the current position. It is initialized with a Position object and a few
|
||||
/// MovePicker is a class which is used to pick one pseudo legal move at a time
|
||||
/// from the current position. It is initialized with a Position object and a few
|
||||
/// moves we have reason to believe are good. The most important method is
|
||||
/// MovePicker::get_next_move(), which returns a new legal move each time it
|
||||
/// is called, until there are no legal moves left, when MOVE_NONE is returned.
|
||||
/// MovePicker::get_next_move(), which returns a new pseudo legal move each time
|
||||
/// it is called, until there are no moves left, when MOVE_NONE is returned.
|
||||
/// In order to improve the efficiency of the alpha beta algorithm, MovePicker
|
||||
/// attempts to return the moves which are most likely to get a cut-off first.
|
||||
|
||||
|
|
|
@ -624,16 +624,19 @@ bool Position::pl_move_is_legal(Move m, Bitboard pinned) const {
|
|||
}
|
||||
|
||||
|
||||
/// Position::move_is_legal() takes a position and a (not necessarily pseudo-legal)
|
||||
/// move and tests whether the move is legal. This version is not very fast and
|
||||
/// should be used only in non time-critical paths.
|
||||
/// Position::move_is_pl_slow() takes a position and a move and tests whether
|
||||
/// the move is pseudo legal. This version is not very fast and should be used
|
||||
/// only in non time-critical paths.
|
||||
|
||||
bool Position::move_is_pl_full(const Move m) const {
|
||||
bool Position::move_is_pl_slow(const Move m) const {
|
||||
|
||||
MoveStack mlist[MAX_MOVES];
|
||||
MoveStack *cur, *last = generate<MV_PSEUDO_LEGAL>(*this, mlist);
|
||||
MoveStack *cur, *last;
|
||||
|
||||
for (cur = mlist; cur != last; cur++)
|
||||
last = in_check() ? generate<MV_EVASION>(*this, mlist)
|
||||
: generate<MV_NON_EVASION>(*this, mlist);
|
||||
|
||||
for (cur = mlist; cur != last; cur++)
|
||||
if (cur->move == m)
|
||||
return true;
|
||||
|
||||
|
@ -641,8 +644,8 @@ bool Position::move_is_pl_full(const Move m) const {
|
|||
}
|
||||
|
||||
|
||||
/// Fast version of Position::move_is_legal() that takes a position a move and
|
||||
/// a bitboard of pinned pieces as input, and tests whether the move is legal.
|
||||
/// Fast version of Position::move_is_pl() that takes a position a move and a
|
||||
/// bitboard of pinned pieces as input, and tests whether the move is pseudo legal.
|
||||
|
||||
bool Position::move_is_pl(const Move m) const {
|
||||
|
||||
|
@ -656,7 +659,7 @@ bool Position::move_is_pl(const Move m) const {
|
|||
|
||||
// Use a slower but simpler function for uncommon cases
|
||||
if (move_is_special(m))
|
||||
return move_is_pl_full(m);
|
||||
return move_is_pl_slow(m);
|
||||
|
||||
// Is not a promotion, so promotion piece must be empty
|
||||
if (move_promotion_piece(m) - 2 != PIECE_TYPE_NONE)
|
||||
|
|
|
@ -186,7 +186,6 @@ public:
|
|||
|
||||
// Properties of moves
|
||||
bool pl_move_is_legal(Move m, Bitboard pinned) const;
|
||||
bool move_is_pl_full(const Move m) const;
|
||||
bool move_is_pl(const Move m) const;
|
||||
bool move_gives_check(Move m) const;
|
||||
bool move_gives_check(Move m, const CheckInfo& ci) const;
|
||||
|
@ -260,6 +259,7 @@ private:
|
|||
void do_allow_oo(Color c);
|
||||
void do_allow_ooo(Color c);
|
||||
bool set_castling_rights(char token);
|
||||
bool move_is_pl_slow(const Move m) const;
|
||||
|
||||
// Helper functions for doing and undoing moves
|
||||
void do_capture_move(Key& key, PieceType capture, Color them, Square to, bool ep);
|
||||
|
|
Loading…
Add table
Reference in a new issue