]> git.sesse.net Git - stockfish/commitdiff
Do not use <algorithm> in to_fen()
authorMarco Costalba <mcostalba@gmail.com>
Sat, 29 Jan 2011 12:14:01 +0000 (13:14 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Sat, 29 Jan 2011 12:28:00 +0000 (13:28 +0100)
Seems there are some problems on HP-UX compiler.

No functional change.

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

index 1bae3620087ff62edb5268ca6902617fb2745f25..ff0c4162a8f4e77303be946d4b68e171b304f6dc 100644 (file)
@@ -17,7 +17,6 @@
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-#include <algorithm>
 #include <cassert>
 #include <cstring>
 #include <fstream>
 #include <cassert>
 #include <cstring>
 #include <fstream>
@@ -77,8 +76,6 @@ namespace {
   // Bonus for having the side to move (modified by Joona Kiiski)
   const Score TempoValue = make_score(48, 22);
 
   // Bonus for having the side to move (modified by Joona Kiiski)
   const Score TempoValue = make_score(48, 22);
 
-  bool isZero(char c) { return c == '0'; }
-
   struct PieceLetters : public std::map<char, Piece> {
 
     PieceLetters() {
   struct PieceLetters : public std::map<char, Piece> {
 
     PieceLetters() {
@@ -341,7 +338,7 @@ const string Position::to_fen() const {
   Square sq;
   char emptyCnt = '0';
 
   Square sq;
   char emptyCnt = '0';
 
-  for (Rank rank = RANK_8; rank >= RANK_1; rank--)
+  for (Rank rank = RANK_8; rank >= RANK_1; rank--, fen += '/')
   {
       for (File file = FILE_A; file <= FILE_H; file++)
       {
   {
       for (File file = FILE_A; file <= FILE_H; file++)
       {
@@ -349,19 +346,23 @@ const string Position::to_fen() const {
 
           if (square_is_occupied(sq))
           {
 
           if (square_is_occupied(sq))
           {
-              fen += emptyCnt;
+              if (emptyCnt != '0')
+              {
+                  fen += emptyCnt;
+                  emptyCnt = '0';
+              }
               fen += pieceLetters.from_piece(piece_on(sq));
               fen += pieceLetters.from_piece(piece_on(sq));
-              emptyCnt = '0';
           } else
               emptyCnt++;
       }
           } else
               emptyCnt++;
       }
-      fen += emptyCnt;
-      fen += '/';
-      emptyCnt = '0';
+
+      if (emptyCnt != '0')
+      {
+          fen += emptyCnt;
+          emptyCnt = '0';
+      }
   }
 
   }
 
-  fen.erase(std::remove_if(fen.begin(), fen.end(), isZero), fen.end());
-  fen.erase(--fen.end());
   fen += (sideToMove == WHITE ? " w " : " b ");
 
   if (st->castleRights != CASTLES_NONE)
   fen += (sideToMove == WHITE ? " w " : " b ");
 
   if (st->castleRights != CASTLES_NONE)