]> git.sesse.net Git - stockfish/commitdiff
A bit of reformatting after previous series
authorMarco Costalba <mcostalba@gmail.com>
Tue, 24 May 2011 07:07:20 +0000 (09:07 +0200)
committerMarco Costalba <mcostalba@gmail.com>
Tue, 24 May 2011 20:24:40 +0000 (21:24 +0100)
And some documentation update.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
src/movegen.cpp
src/movegen.h
src/movepick.cpp
src/movepick.h
src/position.cpp
src/position.h

index 297b51ffdeacb7e6d633be647d9e3da3a89ffc49..e1e6a54b72aa718c55c9c51bc38416f0d13a4e25 100644 (file)
@@ -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) {
 
 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());
 
   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)
 
   // Remove illegal moves from the list
   while (cur != last)
index 6a04248ac3a3199c80f087aaf3a180ff5bc7ad4f..580ca2e74645cfd183b6457ec0c1a6fe594fd5d0 100644 (file)
@@ -30,8 +30,7 @@ enum MoveType {
   MV_NON_CAPTURE_CHECK,
   MV_EVASION,
   MV_NON_EVASION,
   MV_NON_CAPTURE_CHECK,
   MV_EVASION,
   MV_NON_EVASION,
-  MV_LEGAL,
-  MV_PSEUDO_LEGAL
+  MV_LEGAL
 };
 
 template<MoveType>
 };
 
 template<MoveType>
index 2f9cd146010e28c0fa0b6f7523e8f7f5cde2ab14..793a90da39e5efee50922257ebda0fa3860a112b 100644 (file)
@@ -48,8 +48,7 @@ namespace {
 
 bool MovePicker::isBadCapture() const { return phase == PH_BAD_CAPTURES; }
 
 
 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
 /// 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
 }
 
 /// 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
 /// 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
                   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;
           }
               (--badCaptures)->move = move;
               badCaptures->score = seeValue;
           }
@@ -328,7 +327,7 @@ Move MovePicker::get_next_move() {
 
       case PH_QCHECKS:
           move = (curMove++)->move;
 
       case PH_QCHECKS:
           move = (curMove++)->move;
-          if (   move != ttMoves[0].move)
+          if (move != ttMoves[0].move)
               return move;
           break;
 
               return move;
           break;
 
index 5455a3df6a6db3e2f3372a4301e54e5452951a95..fdbd834e43742e63edea39f16cd0bc77a793657f 100644 (file)
 
 struct SearchStack;
 
 
 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
 /// 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.
 
 /// 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.
 
index 4c925f5bba16fc51b8f2417668d0159e47ee450e..867a7f0b947aa00c74f8bc2bf5734a79e63acecc 100644 (file)
@@ -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 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;
 
       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 {
 
 
 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))
 
   // 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)
 
   // Is not a promotion, so promotion piece must be empty
   if (move_promotion_piece(m) - 2 != PIECE_TYPE_NONE)
index 496b7b9d00fe4e763da4f8fcff4bc69448da87ec..af1e981cb3370af138d930d290b2d6d41e98db17 100644 (file)
@@ -186,7 +186,6 @@ public:
 
   // Properties of moves
   bool pl_move_is_legal(Move m, Bitboard pinned) const;
 
   // 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;
   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);
   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);
 
   // Helper functions for doing and undoing moves
   void do_capture_move(Key& key, PieceType capture, Color them, Square to, bool ep);