60 explicit square(
const std::string& pos);
68 explicit square(
const int x,
const int y);
74 int get_x() const noexcept {
return m_x; }
80 int get_y() const noexcept {
return m_y; }
113 const square& attacker_square,
114 const square& target_square,
170 const std::vector<
square>& a,
171 const std::vector<
square>& b
176 std::default_random_engine& rng_engine
193 const
square& pawn_square,
202 const
square& attacker_square,
203 const
square& target_square
265 const std::vector<
square>& occupied_squares
299std::
string to_str(const std::vector<
square>& s) noexcept;
305std::ostream& operator<<(std::ostream& os, const
square& s) noexcept;
306std::ostream& operator<<(std::ostream& os, const std::vector<
square>& s) noexcept;
castling_type
The type of castling.
Definition castling_type.h:9
chess_color
A chess piece color.
Definition chess_color.h:10
An exact coordinate anywhere on the board.
Definition game_coordinate.h:32
A rectangle of game coordinates.
Definition game_rect.h:12
A chess square.
Definition square.h:58
int get_y() const noexcept
Get the y coordinat, starting from 0 for a1/a2/a3/etc.
Definition square.h:80
int get_x() const noexcept
Get the x coordinat, starting from 0 for a1/b1/c1/etc.
Definition square.h:74
piece_action_type
The type of actions a piece can do.
Definition piece_action_type.h:9
bool are_all_unique(std::vector< square > squares)
Are all the squares unique?
Definition square.cpp:50
bool is_valid_square_xy(const int x, const int y) noexcept
Can the x and y be used to create a valid square?
Definition square.cpp:542
square create_random_square(std::default_random_engine &rng_engine)
Create a random square.
Definition square.cpp:299
std::vector< square > collect_all_knight_target_squares(const square &s) noexcept
Collect all the possible target squares for a knight.
Definition square.cpp:192
std::vector< std::vector< square > > collect_all_queen_target_squares(const square &s) noexcept
Collect all the possible target squares for a queen in all directions.
Definition square.cpp:225
square get_behind(const square &pawn_square, const chess_color color)
Get the square behind a pawn.
Definition square.cpp:331
std::vector< std::pair< int, int > > collect_all_bishop_delta_pairs() noexcept
Collect all the delta squares for a bishop.
Definition square.cpp:115
bool are_en_passant_capture_squares(const square &attacker_square, const square &target_square, const chess_color player_color)
Are these possible en-passant capture squares?
Definition square.cpp:68
bool are_on_same_rank(const square &a, const square &b) noexcept
Are the squares on the same rank, e.g. a1 and a8.
Definition square.cpp:110
game_coordinate to_coordinat(const square &s) noexcept
Definition square.cpp:841
bool are_on_same_file(const square &a, const square &b) noexcept
Are the squares on the same file, e.g. e2 and e4.
Definition square.cpp:97
void test_square()
Test this class and its free functions.
Definition square.cpp:556
std::vector< square > to_squares(std::vector< std::pair< int, int > > xys)
Convert the pairs of x-y-coordinats to valid squares.
Definition square.cpp:867
bool are_on_adjacent_diagonal(const square &a, const square &b) noexcept
Are the squares adjacent on the same diagonal, e.g. d1 and e2.
Definition square.cpp:83
std::vector< int > get_all_ranks_in_reversed_order() noexcept
Get all the ranks in reversed order, i.e. 8 to and including 1.
Definition square.cpp:324
std::vector< std::vector< square > > collect_all_rook_target_squares(const square &s) noexcept
Collect all the possible target squares for a rook in all directions.
Definition square.cpp:261
std::vector< square > get_intermediate_squares(const square &from, const square &to)
Get the intermediate squares, in an inclusive way: the first square will be 'from',...
Definition square.cpp:382
bool are_at_knights_jump_distance(const square &a, const square &b) noexcept
Are the squares seperated by the jump of a knight?
Definition square.cpp:60
std::vector< square > concatenate(const std::vector< square > &a, const std::vector< square > &b)
Concatenate the vectors.
Definition square.cpp:287
std::vector< std::pair< int, int > > collect_all_knight_delta_pairs() noexcept
Collect all the delta squares for a knight.
Definition square.cpp:177
std::vector< std::pair< int, int > > collect_all_queen_delta_pairs() noexcept
Collect all the delta squares for a queen.
Definition square.cpp:211
std::vector< std::vector< square > > collect_all_bishop_target_squares(const square &s) noexcept
Collect all the possible target squares for a bishop in all directions.
Definition square.cpp:125
std::vector< square > collect_all_king_target_squares(const square &s) noexcept
Collect all the possible target squares for a king.
Definition square.cpp:151
square get_rook_target_square(const chess_color player_color, const piece_action_type action)
Get the rook target square when castling.
Definition square.cpp:495
std::vector< std::pair< int, int > > collect_all_rook_delta_pairs() noexcept
Collect all the delta squares for a rook.
Definition square.cpp:251
game_rect to_game_rect(const square &s) noexcept
Convert a square to a rectangle For example, a1 == ((0,0)-(1,1)) (notation is top-left,...
Definition square.cpp:854
bool are_on_same_half_diagonal(const square &a, const square &b) noexcept
Are the squares on the same half-diagonal, also 'the jump of a knight' e.g.
Definition square.cpp:102
bool is_occupied(const square &s, const std::vector< square > &occupied_squares) noexcept
Is the square 's' occupied?
Definition square.cpp:530
bool is_invalid_square_xy(const int x, const int y) noexcept
Can the x and y not be used to create a valid square?
Definition square.cpp:547
chess_color to_color(const square &s) noexcept
What is the color of this square?
Definition square.cpp:835
square get_initial_king_square(const chess_color player_color) noexcept
Get the intial king square.
Definition square.cpp:340
square get_king_target_square(const chess_color player_color, const piece_action_type action)
Get the king target square when castling.
Definition square.cpp:462
char get_file(const square &s) noexcept
Get the file of a square, e.g. 'd' from 'd4'.
Definition square.cpp:377
bool are_adjacent(const square &a, const square &b) noexcept
Are the squares adjacent (i.e.
Definition square.cpp:37
int get_rank(const square &s) noexcept
Get the rank of a square, e.g. '3' from 'e3'.
Definition square.cpp:490
std::vector< char > get_all_files() noexcept
Get all the files, i.e. 'a' to and including 'h'.
Definition square.cpp:314
std::string to_str(const square &s) noexcept
Definition square.cpp:894
std::vector< int > get_all_ranks() noexcept
Get all the ranks, i.e. 1 to and including 8.
Definition square.cpp:319
square get_en_passant_capture_square(const square &attacker_square, const square &target_square)
Get the square that may be captured by en-passant.
Definition square.cpp:364
bool are_on_same_diagonal(const square &a, const square &b) noexcept
Are the squares on the same diagonal, e.g. d1 and a4.
Definition square.cpp:90
bool are_adjacent_for_knight(const square &a, const square &b) noexcept
Are the squares adjacent for a knight.
Definition square.cpp:43
square get_initial_rook_square(const chess_color player_color, const castling_type t) noexcept
Get the default rook square, for a castling direction.
Definition square.cpp:347