![]() |
Conquer Chess
Chess and Starcraft combined
|
#include "ccfwd.h"#include "message.h"#include "piece.h"#include "pieces.h"#include "action_history.h"#include "starting_position_type.h"#include "fen_string.h"#include <iosfwd>#include <vector>#include <optional>

Go to the source code of this file.
Classes | |
| class | game |
| The game logic. More... | |
Functions | |
| bool | can_castle_kingside (const piece &p, const game &g) noexcept |
| Can this piece castle kingside? | |
| bool | can_castle_queenside (const piece &p, const game &g) noexcept |
| Can this piece castle queenside? | |
| 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. | |
| 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? | |
| 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? | |
| 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. | |
| 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? | |
| bool | can_do_promote (const piece &selected_piece, const chess_color player_color) |
| Can a piece_action_type::promote_to_bishop action be done? | |
| void | clear_piece_messages (game &g) noexcept |
| Clear the sound effects to be processed, i.e. | |
| action_history | collect_action_history (const game &g) |
| Collect the history of a game, i.e. | |
| std::vector< piece_action > | collect_all_piece_actions (const game &g) |
| Collect all valid moves and attackes at a board for all pieces. | |
| std::vector< piece_action > | collect_all_piece_actions (const game &g, const chess_color player_color) |
| Collect all valid moves and attackes at a board for all pieces of a certain color. | |
| std::vector< piece_action > | collect_all_piece_actions (const game &g, const piece &p) |
| Collect all valid moves and attackes at a board for a focal piece. | |
| 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. | |
| 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. | |
| 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. | |
| 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. | |
| 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. | |
| 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. | |
| 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. | |
| 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. | |
| 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. | |
| std::vector< message > | collect_messages (const game &g) noexcept |
| Get all the sound effects to be processed. | |
| std::vector< message_type > | collect_message_types (const game &g) noexcept |
| See if there are messages. | |
| int | count_piece_actions (const game &g) |
| Count the total number of actions to be done by pieces of both players. | |
| int | count_piece_actions (const game &g, const chess_color player) |
| Count the total number of actions to be done by pieces of a player. | |
| game | create_game_from_fen_string (const fen_string &s) noexcept |
| Create a game from a FEN string. | |
| game | create_game_with_standard_starting_position () noexcept |
| Create a game with all default settings and the default starting position. | |
| 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. | |
| 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. | |
| const piece & | get_closest_piece_to (const game &g, const game_coordinate &coordinat) |
| Get the piece that is closest to the coordinat. | |
| piece & | get_closest_piece_to (game &g, const game_coordinate &coordinat) |
| Get the piece that is closest to the coordinat. | |
| 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. | |
| std::vector< square > | get_unique_occupied_squares (const game &g) noexcept |
| Get all the squares that are occupied, disallowing duplicates. | |
| std::vector< square > | get_occupied_squares (const game &g) noexcept |
| Get all the squares that are occupied, allowing duplicates. | |
| 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. | |
| const piece & | get_piece_at (const game &g, const std::string &square_str) |
| Get the piece that at that square, will throw if there is no piece. | |
| piece & | get_piece_at (game &g, const square &coordinat) |
| Get the piece that at that square, will throw if there is no piece. | |
| piece & | get_piece_at (game &g, const std::string &square_str) |
| Get the piece that at that square, will throw if there is no piece. | |
| const piece & | get_piece_with_id (const game &g, const piece_id &id) |
| Get the piece with a certain ID. | |
| piece & | get_piece_with_id (game &g, const piece_id &id) |
| Get the piece with a certain ID. | |
| std::vector< piece > & | get_pieces (game &g) noexcept |
| Get all the pieces. | |
| const std::vector< piece > & | get_pieces (const game &g) noexcept |
| Get all the pieces. | |
| const in_game_time & | get_time (const game &g) noexcept |
| Get the time in the game. | |
| bool | has_piece_with_id (const game &g, const piece_id &id) |
| Determine if there is a piece at the coordinat. | |
| bool | is_draw (const game &g) |
| Determine if the game is a draw. | |
| bool | is_empty (const game &g, const square &s) noexcept |
| Is the square empty? | |
| 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. | |
| bool | is_empty_between (const game &g, const std::string &from_square_str, const std::string &to_square_str) |
| Are all squares between these two squares empty? Returns true if the squares are adjacent. | |
| bool | is_idle (const game &g) noexcept |
| Are all pieces idle? | |
| 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. | |
| bool | is_piece_at (const game &g, const square &coordinat) |
| Determine if there is a piece at the coordinat. | |
| bool | is_piece_at (const game &g, const std::string &square_str) |
| Determine if there is a piece at the coordinat. | |
| 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. | |
| void | tick (game &g, const delta_t dt) |
| Call game::tick safely. | |
| void | tick_until_idle (game &g) |
| Call game::tick until all pieces are idle. | |
| std::string | to_board_str (const game &g, const board_to_text_options &options=board_to_text_options()) noexcept |
| fen_string | to_fen_string (const game &g) |
| Convert the game's position to a FEN string. | |
| std::string | to_pgn (const game &g) |
| Convert the played game to pseudo-PGN notation. | |
| std::ostream & | operator<< (std::ostream &os, const game &g) noexcept |
Can this piece castle kingside?
Can this piece castle queenside?
| 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.
| 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?
| 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?
| 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.
| 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?
| bool can_do_promote | ( | const piece & | selected_piece, |
| const chess_color | player_color | ||
| ) |
Can a piece_action_type::promote_to_bishop action be done?
|
noexcept |
Clear the sound effects to be processed, i.e.
resize to zero
| action_history collect_action_history | ( | const game & | g | ) |
Collect the history of a game, i.e.
the moves played in time
| 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.
| 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.
| 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.
| 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.
| 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.
| 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.
| 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.
| std::vector< piece_action > collect_all_piece_actions | ( | const game & | g | ) |
Collect all valid moves and attackes at a board for all pieces.
| std::vector< piece_action > collect_all_piece_actions | ( | const game & | g, |
| const chess_color | player_color | ||
| ) |
Collect all valid moves and attackes at a board for all pieces of a certain color.
| std::vector< piece_action > collect_all_piece_actions | ( | const game & | g, |
| const piece & | p | ||
| ) |
Collect all valid moves and attackes at a board for a focal piece.
| 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.
| 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.
|
noexcept |
See if there are messages.
@seealso collect_messages} to get the complete message
Get all the sound effects to be processed.
| int count_piece_actions | ( | const game & | g | ) |
Count the total number of actions to be done by pieces of both players.
| int count_piece_actions | ( | const game & | g, |
| const chess_color | player | ||
| ) |
Count the total number of actions to be done by pieces of a player.
|
noexcept |
Create a game from a FEN string.
|
noexcept |
Create a game with all default settings and the default starting position.
|
noexcept |
Create a game with all default settings and a specific starting position.
| 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.
| const piece & get_closest_piece_to | ( | const game & | g, |
| const game_coordinate & | coordinat | ||
| ) |
Get the piece that is closest to the coordinat.
| piece & get_closest_piece_to | ( | game & | g, |
| const game_coordinate & | coordinat | ||
| ) |
Get the piece that is closest to the coordinat.
| 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.
Get all the squares that are occupied, allowing duplicates.
At the start and end of a tick, all occupied squares must be unique. However, when updating each piece at a time, it can be that some squares are duplicate untill all pieces are processed.
All squares are not tested to be unique, use get_unique_occupied_squares} to guarantee that all squares are unique.
Get the piece that at that square, will throw if there is no piece.
Get the piece that at that square, will throw if there is no piece.
Get the piece that at that square, will throw if there is no piece.
Get the piece that at that square, will throw if there is no piece.
Get the piece with a certain ID.
Assumes that the piece is on the board
Get the piece with a certain ID.
Assumes that the piece is on the board
|
noexcept |
Get the time in the game.
Get all the squares that are occupied, disallowing duplicates.
At the start and end of a tick, all occupied squares must be unique. However, when updating each piece at a time, it can be that some squares are duplicate untill all pieces are processed.
All squares are tested to be unique, use get_occupied_squares} to allow duplicate squares.
Determine if there is a piece at the coordinat.
| bool is_draw | ( | const game & | g | ) |
Determine if the game is a draw.
Are all squares between these two squares empty? Returns true if the squares are adjacent.
| bool is_empty_between | ( | const game & | g, |
| const std::string & | from_square_str, | ||
| const std::string & | to_square_str | ||
| ) |
Are all squares between these two squares empty? Returns true if the squares are adjacent.
|
noexcept |
Are all pieces idle?
| 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.
Determine if there is a piece at the coordinat.
| bool is_piece_at | ( | const game & | g, |
| const std::string & | square_str | ||
| ) |
Determine if there is a piece at the coordinat.
| 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.
If the square is empty, it will determine if an enemy piece is looking at this square.
If the square is occupied, it will determine if an enemy piece is looking at that piece. That piece can be of any color.
|
noexcept |
Call game::tick safely.
That is, with a maximum delta t of 0.25
| void tick_until_idle | ( | game & | g | ) |
Call game::tick until all pieces are idle.
|
noexcept |
| fen_string to_fen_string | ( | const game & | g | ) |
Convert the game's position to a FEN string.
| std::string to_pgn | ( | const game & | g | ) |
Convert the played game to pseudo-PGN notation.
Returns one string with newlines. An example string can be: '0: white pawn move from e2 to e4', where the '0' denotes the starting time of the move