summaryrefslogtreecommitdiff
path: root/src/ChessArbiter.hpp
blob: 09d8295d8f34853d689c97b0bfa76ad6f45d63fb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#pragma once
#include "Board.hpp"
#include "Fen.hpp"
#include <iostream>
#include <unordered_map>

namespace chessarbiter {
class ChessArbiter {
  Board board;
  FEN fen;
  FEN fen_last; // To undo a move
  int wPawn, wRook, wKnight, wBishop, wQueen, wKing;
  /// @brief Use to compute occurences of positions
  std::unordered_map<std::string, char> positions;
  /// @brief FEN methods used internally
  void SetFEN(std::string);
  void SetFEN(FEN);

public:
  ChessArbiter();
  void Setup(std::string);
  std::string GetFEN();
  /// @brief Check which player is going to play
  bool IsBlackTurn();
  /// @brief Check if a side is in check
  bool IsCheck(bool);
  /// @brief Play a move (return false if it's illegal)
  bool Play(std::string);
  /// @brief Check if a square is attacked by a particular player
  bool IsAttacked(std::string, bool);
  /// @brief Get the serialized board
  std::string GetBoard();
  /// @brief Get current position evaluation according to player's material
  int GetMaterialScore();
  /// @brief Check if position is legal to be played
  bool IsPlayable();
  /// @brief Get pieces captures by a player
  std::string GetCaptures(bool);
  /// @brief List all the legal moves of a player
  std::vector<std::string> ListLegalMoves(bool);
  /// @brief Check if a specific castle is possible by a player
  bool IsCastlePossible(bool, bool);
  bool IsCheckMate();
  /// @brief Draws check
  bool IsDrawByFiftyMoveRule();
  bool IsDrawByNoMoves();
  bool IsDrawByRepetitions();
  bool IsDraw();
};
} // namespace chessarbiter