]> git.sesse.net Git - stockfish/blobdiff - src/san.cpp
Unify move generation
[stockfish] / src / san.cpp
index 963ea7c9f8bddc52f1b099215c8113cf7bdd4eaa..1eb59c32fb17bca173466a764d7e090710ab6ed5 100644 (file)
@@ -73,9 +73,9 @@ const string move_to_san(Position& pos, Move m) {
   if (m == MOVE_NULL)
       return "(null)";
 
-  if (move_is_long_castle(m)  || (int(to - from) == -2 && pt == KING))
+  if (move_is_long_castle(m))
       san = "O-O-O";
-  else if (move_is_short_castle(m) || (int(to - from) ==  2 && pt == KING))
+  else if (move_is_short_castle(m))
       san = "O-O";
   else
   {
@@ -149,7 +149,7 @@ Move move_from_san(const Position& pos, const string& movestr) {
   int matches, state = START;
 
   // Generate all legal moves for the given position
-  last = generate_moves(pos, mlist);
+  last = generate<MV_LEGAL>(pos, mlist);
 
   // Castling moves
   if (movestr == "O-O-O" || movestr == "O-O-O+")
@@ -377,7 +377,7 @@ namespace {
         return AMBIGUITY_NONE;
 
     // Collect all legal moves of piece 'pc' with destination 'to'
-    last = generate_moves(pos, mlist);
+    last = generate<MV_LEGAL>(pos, mlist);
     for (MoveStack* cur = mlist; cur != last; cur++)
         if (move_to(cur->move) == to && pos.piece_on(move_from(cur->move)) == pc)
             candidates[matches++] = cur->move;