36 const auto&
get_pieces() const noexcept {
return m_pieces; }
42 const auto&
get_winner() const noexcept {
return m_winner; }
54 std::vector<piece> m_pieces;
60 std::optional<chess_color> m_winner;
68 void check_all_occupied_squares_are_unique()
const;
75 void check_game_and_pieces_agree_on_the_time()
const;
78 void check_if_there_is_a_winner();
83 void tick_impl(
const delta_t& dt);
99 const piece& selected_piece,
100 const square& cursor_square,
107 const piece& selected_piece,
114 const piece& selected_piece,
123 const piece& selected_piece,
124 const square& cursor_square,
131 const piece& selected_piece,
132 const square& cursor_square,
138 const piece& selected_piece,
289game get_kings_only_game() noexcept;
371 const std::
string& from_square_str,
372 const std::
string& to_square_str
382 const
double distance = 0.5
394 const std::
string& square_str
434std::ostream& operator<<(std::ostream& os, const
game& g) noexcept;
chess_color
A chess piece color.
Definition chess_color.h:10
The collected in-game times of actions, in chrononical order.
Definition action_history.h:17
Options on how to convert a chessboard to text.
Definition board_to_text_options.h:10
A change of in_game_time}.
Definition delta_t.h:12
Forsyth–Edwards Notation string.
Definition fen_string.h:20
An exact coordinate anywhere on the board.
Definition game_coordinate.h:32
The game logic.
Definition game.h:28
auto & get_pieces() noexcept
Get all the pieces.
Definition game.h:33
const auto & get_pieces() const noexcept
Get all the pieces.
Definition game.h:36
const auto & get_in_game_time() const noexcept
Get the in-game time.
Definition game.h:40
void tick(const delta_t &dt)
Go to the next frame.
Definition game.cpp:1233
friend game create_game_with_starting_position(starting_position_type t) noexcept
const auto & get_winner() const noexcept
Definition game.h:42
The in-game time, in chess moves.
Definition in_game_time.h:16
A unique ID.
Definition piece_id.h:12
A chess piece.
Definition piece.h:24
A chess square.
Definition square.h:58
fen_string to_fen_string(const game &g)
Convert the game's position to a FEN string.
Definition game.cpp:1317
std::vector< piece_action > collect_all_pawn_actions(const game &g, const piece &p)
Collect all valid moves and attacks at a board for a focal pawn.
Definition game.cpp:564
bool can_castle_queenside(const piece &p, const game &g) noexcept
Can this piece castle queenside?
Definition game.cpp:73
std::vector< piece_action > collect_all_pawn_move_actions(const game &g, const piece &p)
Collect all valid move actions at a board for a focal pawn.
Definition game.cpp:731
const piece & get_closest_piece_to(const game &g, const game_coordinate &coordinat)
Get the piece that is closest to the coordinat.
Definition game.cpp:981
bool is_empty_between(const game &g, const square &from, const square &to)
Are all squares between these two squares empty? Returns true if the squares are adjacent.
Definition game.cpp:1168
bool can_do_castle_kingside(const game &g, const piece &selected_piece, const chess_color player_color)
Can a piece_action_type::castle_kingside action be done?
Definition game.cpp:147
std::vector< piece_action > collect_all_piece_actions(const game &g)
Collect all valid moves and attackes at a board for all pieces.
Definition game.cpp:298
void tick(game &g, const delta_t dt)
Call game::tick safely.
Definition game.cpp:1289
std::vector< piece > find_pieces(const game &g, const piece_type type, const chess_color color)
Find zero, one or more chess pieces of the specified type and color.
Definition game.cpp:961
bool is_draw(const game &g)
Determine if the game is a draw.
Definition game.cpp:1157
action_history collect_action_history(const game &g)
Collect the history of a game, i.e.
Definition game.cpp:293
bool can_do_promote(const piece &selected_piece, const chess_color player_color)
Can a piece_action_type::promote_to_bishop action be done?
Definition game.cpp:238
std::vector< message > collect_messages(const game &g) noexcept
Get all the sound effects to be processed.
Definition game.cpp:1080
bool can_do_castle_queenside(const game &g, const piece &selected_piece, const chess_color player_color)
Can a piece_action_type::castle_queenside action be done?
Definition game.cpp:159
std::vector< piece_action > collect_all_king_actions(const game &g, const piece &p)
Collect all valid moves and attacks at a board for a focal king.
Definition game.cpp:460
const piece & get_piece_with_id(const game &g, const piece_id &id)
Get the piece with a certain ID.
Definition game.cpp:1060
bool is_empty(const game &g, const square &s) noexcept
Is the square empty?
Definition game.cpp:1163
bool can_do_en_passant(const game &g, const piece &selected_piece, const square &cursor_square, const chess_color player_color)
Can a piece_action_type::en_passant action be done? This is not a regular attack.
Definition game.cpp:171
std::vector< piece_action > collect_all_queen_actions(const game &g, const piece &p)
Collect all valid moves and attacks at a board for a focal queen.
Definition game.cpp:854
std::vector< piece_action > collect_all_rook_actions(const game &g, const piece &p)
Collect all valid moves and attacks at a board for a focal rook.
Definition game.cpp:900
std::string to_pgn(const game &g)
Convert the played game to pseudo-PGN notation.
Definition game.cpp:1335
bool is_piece_at(const game &g, const game_coordinate &coordinat, const double distance=0.5)
Determine if there is a piece at the coordinat.
Definition game.cpp:1202
game create_game_with_standard_starting_position() noexcept
Create a game with all default settings and the default starting position.
Definition game.cpp:1005
std::string to_board_str(const game &g, const board_to_text_options &options=board_to_text_options()) noexcept
Definition game.cpp:1306
bool has_piece_with_id(const game &g, const piece_id &id)
Determine if there is a piece at the coordinat.
Definition game.cpp:1145
std::vector< piece > & get_pieces(game &g) noexcept
Get all the pieces.
Definition game.cpp:1050
bool can_do_attack(const game &g, const piece &selected_piece, const square &cursor_square, const chess_color player_color)
Can a piece_action_type::attack action be done? This is not an en-passant.
Definition game.cpp:109
int count_piece_actions(const game &g)
Count the total number of actions to be done by pieces of both players.
Definition game.cpp:946
bool can_castle_kingside(const piece &p, const game &g) noexcept
Can this piece castle kingside?
Definition game.cpp:37
const in_game_time & get_time(const game &g) noexcept
Get the time in the game.
Definition game.cpp:1140
bool is_idle(const game &g) noexcept
Are all pieces idle?
Definition game.cpp:1197
std::vector< message_type > collect_message_types(const game &g) noexcept
See if there are messages.
Definition game.cpp:1104
void clear_piece_messages(game &g) noexcept
Clear the sound effects to be processed, i.e.
Definition game.cpp:288
game create_game_with_starting_position(starting_position_type t, const race lhs_race=race::classic, const race rhs_race=race::classic) noexcept
Create a game with all default settings and a specific starting position.
Definition game.cpp:1010
std::vector< piece_action > collect_all_bishop_actions(const game &g, const piece &p)
Collect all valid moves and attacks at a board for a focal bishop.
Definition game.cpp:414
std::vector< square > get_occupied_squares(const game &g) noexcept
Get all the squares that are occupied, allowing duplicates.
Definition game.cpp:1038
bool can_do_move(const game &g, const piece &selected_piece, const square &cursor_square, const chess_color player_color)
Can a piece_action_type::move action be done?
Definition game.cpp:207
std::vector< square > get_unique_occupied_squares(const game &g) noexcept
Get all the squares that are occupied, disallowing duplicates.
Definition game.cpp:1033
std::vector< piece_action > collect_all_pawn_en_passant_actions(const game &g, const piece &p)
Collect all valid attack actions at a board for a focal pawn.
Definition game.cpp:650
std::vector< piece_action > collect_all_pawn_attack_actions(const game &g, const piece &p)
Collect all valid attack actions at a board for a focal pawn.
Definition game.cpp:584
int get_index_of_closest_piece_to(const game &g, const game_coordinate &coordinat)
Get the index of the piece that is closest to the coordinat.
Definition game.cpp:1020
void tick_until_idle(game &g)
Call game::tick until all pieces are idle.
Definition game.cpp:1295
std::vector< piece_action > collect_all_knight_actions(const game &g, const piece &p)
Collect all valid moves and attacks at a board for a focal knight.
Definition game.cpp:524
bool is_square_attacked(const game &g, const square &s, const chess_color attacker_color)
Determine if the square is attacked by (another) piece of a certain color.
Definition game.cpp:1224
game create_game_from_fen_string(const fen_string &s) noexcept
Create a game from a FEN string.
Definition game.cpp:997
const piece & get_piece_at(const game &g, const square &coordinat)
Get the piece that at that square, will throw if there is no piece.
Definition game.cpp:1119
piece_type
The type of chess piece.
Definition piece_type.h:9
std::vector< piece > get_standard_starting_pieces(const race white_race=race::classic, const race black_race=race::classic) noexcept
Get all the pieces in the starting position.
Definition pieces.cpp:916
race
The chess race.
Definition race.h:10
starting_position_type
The starting position type.
Definition starting_position_type.h:10