nicolaswinkler 7 tahun lalu
induk
melakukan
e4bb7928ad
6 mengubah file dengan 35 tambahan dan 32 penghapusan
  1. 11 3
      src/BitBoard.h
  2. 0 1
      src/Board.h
  3. 0 4
      src/ChessGame.h
  4. 3 5
      src/Minimax.cpp
  5. 20 19
      src/MoveGeneration.cpp
  6. 1 0
      src/MoveGeneration.h

+ 11 - 3
src/BitBoard.h

@@ -83,6 +83,8 @@ struct chessy::Move
     //! it is indicated, that no promotion happened.
     //! it is indicated, that no promotion happened.
     PieceType promotion;
     PieceType promotion;
 
 
+    bool isCastling;
+
 
 
     Move            (void)          = default;
     Move            (void)          = default;
     Move            (const Move&)   = default;
     Move            (const Move&)   = default;
@@ -92,7 +94,7 @@ struct chessy::Move
     Move& operator= (Move&&)        = default;
     Move& operator= (Move&&)        = default;
 
 
     inline Move(const std::string& move) :
     inline Move(const std::string& move) :
-        promotion{ PieceType::PAWN }
+        promotion{ PieceType::PAWN }, isCastling{ false }
     {
     {
         if (move.length() < 4)
         if (move.length() < 4)
             return;
             return;
@@ -110,10 +112,16 @@ struct chessy::Move
 
 
     inline Move(Index origin, Index destination) :
     inline Move(Index origin, Index destination) :
         origin{ origin }, destination{ destination },
         origin{ origin }, destination{ destination },
-        promotion{ PieceType::PAWN } {}
+        promotion{ PieceType::PAWN }, isCastling{ false } {}
 
 
     inline Move(Index origin, Index destination, PieceType promotion) :
     inline Move(Index origin, Index destination, PieceType promotion) :
-        origin{ origin }, destination{ destination }, promotion{ promotion } {}
+        origin{ origin }, destination{ destination }, promotion{ promotion },
+        isCastling{ false } {}
+
+    inline Move(Index origin, Index destination, PieceType promotion,
+        bool isCastling) :
+        origin{ origin }, destination{ destination }, promotion{ promotion },
+        isCastling{ isCastling } {}
 
 
     inline std::string asString(void) const
     inline std::string asString(void) const
     {
     {

+ 0 - 1
src/Board.h

@@ -8,7 +8,6 @@
 
 
 namespace chessy
 namespace chessy
 {
 {
-
     class Board;
     class Board;
 }
 }
 
 

+ 0 - 4
src/ChessGame.h

@@ -28,10 +28,6 @@ class chessy::ChessGame
 
 
     int moveCount =                 1;
     int moveCount =                 1;
 
 
-    /*const static char WHITE =       0;
-    const static char BLACK =       1;*/
-
-
 public:
 public:
 
 
     ChessGame(void);
     ChessGame(void);

+ 3 - 5
src/Minimax.cpp

@@ -206,19 +206,17 @@ MiniMax::BestMove MiniMax::minimax(int depth)
         board = temp;
         board = temp;
     }
     }
 
 
-    /*Bitboard& king = board.getKing<side>();
-    Index kingIndex = king.getLeastSignificantBit();
-    for (auto pos : KingMoveGenerator{ king, friends }) {
+    for (auto pos : CastlingGenerator<side>{ game }) {
         Move move = { kingIndex, pos };
         Move move = { kingIndex, pos };
-        board.removeAt(pos);
         king.applyMove(move);
         king.applyMove(move);
+        
         BestMove m = minimax<otherSide(side)>(depth - 1);
         BestMove m = minimax<otherSide(side)>(depth - 1);
         m.move = move;
         m.move = move;
         //if (depth >= 3)
         //if (depth >= 3)
         //    std::cout << m.move.asString() << " " << bestMove.value << " -> " << m.value << std::endl;
         //    std::cout << m.move.asString() << " " << bestMove.value << " -> " << m.value << std::endl;
         bestMove.overwriteIfBetter(m);
         bestMove.overwriteIfBetter(m);
         board = temp;
         board = temp;
-    }*/
+    }
 
 
 
 
     float v = evaluate<side>();
     float v = evaluate<side>();

+ 20 - 19
src/MoveGeneration.cpp

@@ -3,25 +3,6 @@
 
 
 using namespace chessy;
 using namespace chessy;
 
 
-namespace chessy
-{
-    template class PawnPushGenerator<WHITE_SIDE>;
-    template class PawnPushGenerator<BLACK_SIDE>;
-
-    template class PromotionGenerator<WHITE_SIDE>;
-    template class PromotionGenerator<BLACK_SIDE>;
-
-    template class PawnDoublePushGenerator<WHITE_SIDE>;
-    template class PawnDoublePushGenerator<BLACK_SIDE>;
-
-    template class PawnCaptureGenerator<WHITE_SIDE, LEFT>;
-    template class PawnCaptureGenerator<WHITE_SIDE, RIGHT>;
-    template class PawnCaptureGenerator<BLACK_SIDE, LEFT>;
-    template class PawnCaptureGenerator<BLACK_SIDE, RIGHT>;
-
-    template class CastlingGenerator<WHITE_SIDE>;
-    template class CastlingGenerator<BLACK_SIDE>;
-}
 
 
 
 
 template<Side side>
 template<Side side>
@@ -225,3 +206,23 @@ CastlingGenerator<side>::CastlingGenerator(const ChessGame& game) :
 }
 }
 
 
 
 
+// explicit instatiations
+namespace chessy
+{
+    template class PawnPushGenerator<WHITE_SIDE>;
+    template class PawnPushGenerator<BLACK_SIDE>;
+
+    template class PromotionGenerator<WHITE_SIDE>;
+    template class PromotionGenerator<BLACK_SIDE>;
+
+    template class PawnDoublePushGenerator<WHITE_SIDE>;
+    template class PawnDoublePushGenerator<BLACK_SIDE>;
+
+    template class PawnCaptureGenerator<WHITE_SIDE, LEFT>;
+    template class PawnCaptureGenerator<WHITE_SIDE, RIGHT>;
+    template class PawnCaptureGenerator<BLACK_SIDE, LEFT>;
+    template class PawnCaptureGenerator<BLACK_SIDE, RIGHT>;
+
+    template class CastlingGenerator<WHITE_SIDE>;
+    template class CastlingGenerator<BLACK_SIDE>;
+}

+ 1 - 0
src/MoveGeneration.h

@@ -288,6 +288,7 @@ template<chessy::Side side>
 class chessy::CastlingGenerator :
 class chessy::CastlingGenerator :
     public PositionSet
     public PositionSet
 {
 {
+public:
     CastlingGenerator(const ChessGame& game);
     CastlingGenerator(const ChessGame& game);
 };
 };