Advertisement
loloof64

IPosition.h

Apr 12th, 2020
592
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.90 KB | None | 0 0
  1. #ifndef IPOSITION_H
  2. #define IPOSITION_H
  3.  
  4. #include <string>
  5.  
  6. namespace loloof64 {
  7.  
  8.     enum File {
  9.         FILE_A,
  10.         FILE_B,
  11.         FILE_C,
  12.         FILE_D,
  13.         FILE_E,
  14.         FILE_F,
  15.         FILE_G,
  16.         FILE_H
  17.     };
  18.  
  19.     enum Rank {
  20.         RANK_1,
  21.         RANK_2,
  22.         RANK_3,
  23.         RANK_4,
  24.         RANK_5,
  25.         RANK_6,
  26.         RANK_7,
  27.         RANK_8
  28.     };
  29.  
  30.     class UnimplementedException{};
  31.  
  32.     class IPosition {
  33.     public:
  34.         IPosition(){}
  35.         ~IPosition(){}
  36.         // Should return the position in Forsyth-Edwards Notation
  37.         virtual std::string getFen() const { UnimplementedException ex; throw ex; }
  38.  
  39.         // Should return true for white turn, and false for black turn
  40.         virtual bool isWhiteTurn() const { UnimplementedException ex; throw ex; }
  41.  
  42.         // Should return the piece value in Forsyth-Edwards Notation ('P' = white pawn, 'n' = black knight, ...)
  43.         virtual char getPieceFenAt(int /*file*/ , int /*rank*/) const { UnimplementedException ex; throw ex; }
  44.  
  45.         // Should return true is, and only if, the given move is legal
  46.         virtual bool isLegalMove(
  47.                 int /*startFile*/, int /*startRank*/, int /*endFile*/, int /*endRank*/) const
  48.             { UnimplementedException ex; throw ex; }
  49.  
  50.         // Should make the given move if legal
  51.         // promotionFen should be 'q' or 'Q' (either value whatever the side to move) for queen, 'r' or 'R' for rook,
  52.         // 'b' or 'B' for bishop, or 'n' or 'N' for knight. Or the value 0 for leaving this field set to no_promotion.
  53.         // Should return the new position in Forsyth-Edwards Notation, or throw an error if the move could not be applied
  54.         // because it is illegal.
  55.         virtual std::string makeMove(
  56.                 int /*startFile*/, int /*startRank*/, int /*endFile*/, int /*endRank*/, char /* promotionFen*/ = 0)
  57.         { UnimplementedException ex; throw ex;}
  58.  
  59.         // Should tells whether the given move leads to a promotion, and return false if either no or move is illegal.
  60.         virtual bool isPromotionMove(
  61.                 int /*startFile*/, int /*startRank*/, int /*endFile*/, int /*endRank*/) const
  62.         { UnimplementedException ex; throw ex;}
  63.  
  64.         // Should return true if it is checkmate, false otherwise.
  65.         virtual bool isCheckmate() const;
  66.  
  67.         // Should return true if it is stalemate, false otherwise.
  68.         virtual bool isStalemate() const;
  69.  
  70.         // Should return true if it is draw by insuficient material, false otherwise.
  71.         virtual bool isInsuficientMaterialDraw() const;
  72.  
  73.         // Should return true if it is draw by 3-folds repetitions, false otherwise.
  74.         virtual bool isThreeFoldRepetitionsDraw() const;
  75.  
  76.         // Should return true if it is draw by the 50-moves rule, false otherwise.
  77.         virtual bool isFiftyMovesRuleDraw();
  78.     };
  79. }
  80.  
  81. #endif // IPOSITION_H
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement