10#include <initializer_list>
123 int x()
const {
return p_x; };
128 int y()
const {
return p_y; };
135 char letter()
const {
return p_x +
'a' - 1; };
339 const Piece* cap =
nullptr,
416 virtual void apply(
int mode = 0);
471 virtual auto clone() const ->
std::decay<decltype(*this)>::type*;
472 virtual ~
Turn() = default;
675 virtual ~Piece() =
default;
730 return b_currentTurnColor;
898 virtual void clear();
926 void fill(PieceSetT& set);
950 template<
class Iterator>
951 void fill(Iterator begin, Iterator end);
993 friend bool operator!=(
const Board&,
const Board&);
1017 using BoardT::iterator;
1018 using BoardT::const_iterator;
1019 using BoardT::begin;
1052 PieceTypesRetT getPieceType(PieceTypesArgT possible);
1095 template<
class Iterator>
1096 PieceSetT set(Iterator begin, Iterator end)
const;
1114 void fillBoardWithNullptrs();
8x8 game board
Definition board.hpp:690
HistoryT & history()
Turn history.
Definition board.hpp:842
void setPieceGetter(PieceGetterT g)
Set the Piece getter functor.
Definition board.hpp:1027
virtual std::string str() const =0
String representation of Board.
virtual PieceSetT defaultPieceSet() const =0
Default piece set for the Board.
Piece::Color currentTurn() const
Current turn color.
Definition board.hpp:729
Board & operator=(Board &&)=default
Move assignment operator.
HistoryT b_history
Board history of applied Turn objects.
Definition board.hpp:1137
const BoardT & board() const
Internal board data structure.
Definition board.hpp:831
PieceGetterT b_pieceGetter
Piece getter variable.
Definition board.hpp:1148
Board(Board &&)=default
Move constructor.
std::size_t turnIndex() const
Turn index.
Definition board.hpp:864
virtual bool isEqual(const Board &other) const =0
Compare 2 Board objects.
std::size_t movesMade() const
Total count of moves made on Board.
Definition board.hpp:853
const PieceGetterT & pieceGetter() const
Set the Piece getter functor.
Definition board.hpp:1038
CapturedT b_capturedPieces
List of captured pieces.
Definition board.hpp:1128
BoardT & board()
Internal board data structure.
Definition board.hpp:835
virtual Piece * piece(const std::string &spec) const =0
Convert std::string Piece spec to actual Piece object pointer.
const HistoryT & history() const
Turn history.
Definition board.hpp:846
virtual const Piece::Turn * makeTurn(const Piece::Position &from, const Piece::Position &to)=0
Make the turn.
PieceGetterT & pieceGetter()
Get current piece getter functor.
Definition board.hpp:1034
void refill()
Clear and fill Board with default piece set.
Definition board.hpp:960
Piece position at the Board.
Definition board.hpp:36
char setLetter(char x)
Set x coordinate with string representation.
Definition board.hpp:165
std::string str() const
String position representation.
Definition position.cpp:115
Position()=default
Create Position object at a1.
Position operator-(const Position &) const
Substraction operator.
Definition position.cpp:132
Mode mode() const
Current mode.
Definition board.hpp:251
bool atLeft() const
Check if the position are at left border.
Definition position.cpp:76
bool atRight() const
Check if the position are at right border.
Definition position.cpp:83
Position offset(int dx, int dy) const
Offset current position.
Definition position.cpp:65
Position(const char *str)
Creates Position object at str position.
Definition board.hpp:104
Position operator-=(const Position &)
cosnt
Definition position.cpp:140
int x() const
x coordinate
Definition board.hpp:123
int setX(int x)
Set x coordinate.
Definition position.cpp:39
Position operator()(int dx, int dy) const
Offset current position.
Definition position.cpp:144
int y() const
y coordinate
Definition board.hpp:128
friend std::ostream & operator<<(std::ostream &, const Position &)
std::ostream output operator
Definition position.cpp:156
friend bool operator==(const Position &, const Position &)
Comparison operator.
Definition position.cpp:152
Position & operator=(const Position &)
Copy assignment operator.
Definition position.cpp:122
Mode
Boolean functions operation mode.
Definition board.hpp:45
@ Reverse
Place origin at the h8.
@ Normal
Place origin at the a1.
int setDigit(short y)
Set y coordinate.
Definition board.hpp:171
bool atBottom() const
Check if the position are at bottom border.
Definition position.cpp:97
int digit() const
Digit representation of y coordinate.
Definition board.hpp:142
int setY(int y)
Set y coordinate.
Definition position.cpp:52
Mode setMode(Mode m)
Set offset mode.
Definition position.cpp:104
Position operator+(const Position &) const
Addition operator.
Definition position.cpp:128
char letter() const
Letter representation of x coordinate.
Definition board.hpp:135
bool atTop() const
Check if the position are at top border.
Definition position.cpp:90
Position operator+=(const Position &)
cosnt
Definition position.cpp:136
List of Turn objects.
Definition board.hpp:489
Generic Piece Turn on Board.
Definition board.hpp:325
const Piece * piece() const
Turn Piece.
Definition board.hpp:359
friend bool operator!=(const Turn &, const Turn &)
Inverted comparison operator.
Definition turn.cpp:63
Position from() const
Position the turn is started at.
Definition board.hpp:353
bool possible() const
Turn viability.
Definition board.hpp:380
friend std::ostream & operator<<(std::ostream &os, const Turn &t)
std::ostream output
Definition turn.cpp:68
virtual std::string str() const
String Turn representation.
Definition turn.cpp:47
Position t_to
Turn piece finishing position
Definition board.hpp:477
Piece * t_capture
Piece that is captured as the resul of turn.
Definition board.hpp:481
bool t_possible
Turn viability.
Definition board.hpp:483
Piece * piece()
Turn Piece.
Definition board.hpp:363
Piece * capture()
Captured piece.
Definition board.hpp:374
Position to() const
Position where piece will end up after turn.
Definition board.hpp:347
virtual void undo()
Undo turn.
Definition turn.cpp:28
Piece * t_piece
Turn Piece inself
Definition board.hpp:479
const Piece * capture() const
Captured piece.
Definition board.hpp:370
bool setPossible(bool c)
Set the turn viability.
Definition board.hpp:387
friend bool operator==(const Turn &lhs, const Turn &rhs)
Comparison operator.
Definition turn.cpp:59
virtual void apply(int mode=0)
Apply turn.
Definition turn.cpp:18
Position t_from
Turn piece starting position
Definition board.hpp:475
virtual auto clone() const -> std::decay< decltype(*this)>::type *
Clone current Turn.
Definition turn.cpp:72
virtual bool isEqual(const Turn &rhs) const
Compare turns.
Definition turn.cpp:39
Generic board memeber API.
Definition board.hpp:23
std::size_t movesMade() const
Moves count.
Definition board.hpp:639
Position & position()
Piece Position.
Definition board.hpp:580
Board * setBoard(Board *b)
Set Piece Board.
Definition piece.cpp:11
Board * p_board
Piece Board.
Definition board.hpp:542
const Board * board() const
Piece board.
Definition board.hpp:620
static TurnMap straightMoves(const Piece *p)
Construct straight moves (up, down, left, right) TurnMap.
Definition piece.cpp:79
Color p_color
Piece color.
Definition board.hpp:530
virtual Position move(const Position &to)
Move piece.
Definition piece.cpp:17
Position setPosition(const Position &)
Set Piece position.
Definition piece.cpp:30
virtual TurnMap moveMap(int mode=0) const =0
Generic moves.
Color setColor(Color col)
Set the color.
Definition piece.cpp:36
Position p_position
Piece Position.
Definition board.hpp:535
Color color() const
Piece color.
Definition board.hpp:561
std::size_t p_movesMade
Turns count Count of turns Piece have made.
Definition board.hpp:547
std::size_t turnIndex() const
Current turn index.
Definition board.hpp:647
Color
Piece color.
Definition board.hpp:30
const Position & position() const
Piece Position.
Definition board.hpp:576
std::size_t p_turnIndex
Last turn index.
Definition board.hpp:554
Board * board()
Piece board.
Definition board.hpp:624
static TurnMap diagonalMoves(const Piece *p)
Construct diagonal moves TurnMap.
Definition piece.cpp:42
Tartan library namespace.
Definition board.cpp:10
std::ostream & operator<<(std::ostream &os, const Board &cb)
Definition board.cpp:235
bool operator==(const Board &lhs, const Board &rhs)
Definition board.cpp:243