10 for(
int i = 0; i < 8; i++){
23 for(
int i = 0; i < 8; i++){
36 for(
int i = 0; i < 8; i++){
37 for(
int j = 0; j < 8; j++){
54 last_move(other.last_move), last_move_en_passant_eligible(other.last_move_en_passant_eligible)
106 for(
int i = 0; i < 8; i++){
107 for(
int j = 0; j < 8; j++){
131 std::cout << std::endl;
137 bool switcher =
false;
138 for(
int i = 0; i < 8; i++){
140 if((switcher&&!inverted)||(!switcher&&inverted)){
146 switcher = !switcher;
152 std::cout <<
" a b c d e f g h ";
157 bool line_switcher =
true;
158 bool column_switcher =
false;
161 for(
int y = 7; y > -1; y--){
170 column_switcher =
true;
172 if((line_switcher&&!column_switcher)||(!line_switcher&&column_switcher)){
178 for(
int x = 0; x < 8; x++){
187 std::cout <<
" " << y + 1;
191 column_switcher = !column_switcher;
192 if((line_switcher&&!column_switcher)||(!line_switcher&&column_switcher)){
209 line_switcher = !line_switcher;
211 std::cout <<
" a b c d e f g h " << std::endl;
226 for(
int y = 0; y < 8; y++){
227 for(
int x = 0; x < 8; x++){
241 bool piece_found =
false;
242 for(
int i = 0; i <
white_pieces.size() && !piece_found; i++){
248 for(
int i = 0; i <
black_pieces.size() && !piece_found; i++){
276 (abs(move_to.
get_y() - move_from.
get_y()) == 2);
311 if(move_from.
get_x() < 0 || move_from.
get_x() > 7 || move_from.
get_y() < 0 || move_from.
get_y() > 7 ||
325 std::vector<coordinates> empty_check = {};
356 for(
int i = 0; i < empty_check.size(); i++){
357 result = result && (
board_data[empty_check[i].get_x()][empty_check[i].get_y()] ==
nullptr);
367 int result_y = atoi(&move[1]) - 1;
369 std::vector<char> x_traduction = {
'a',
'b',
'c',
'd',
'e',
'f',
'g',
'h'};
370 for(
int i = 0; i < 8; i++){
371 if(move[0] == x_traduction[i]){
553 board *chess_board_copy;
562 for(
int j = 0; j <
black_pieces[i]->get_legals().size(); j++){
564 chess_board =
new board(*
this);
569 if(chess_board->
is_legal(start,end,!white_move)){
571 chess_board_copy =
new board(*chess_board);
572 chess_board_copy->
move(start,end);
573 if(chess_board_copy->
is_check(!white_move)){
579 delete chess_board_copy;
588 for(
int j = 0; j <
white_pieces[i]->get_legals().size(); j++){
590 chess_board =
new board(*
this);
595 if(chess_board->
is_legal(start,end,!white_move)){
597 chess_board_copy =
new board(*chess_board);
598 chess_board_copy->
move(start,end);
599 if(chess_board_copy->
is_check(!white_move)){
605 delete chess_board_copy;
void print_neutral_endl()
print a neutral font color and background color new line
coordinates get_coord_from_string(std::string move)
Retrieve coordinates from a string.
void print_line_separator(bool inverted)
print a line separator with board matching background colors
void print_neutral_endl()
print a neutral font color and background color new line
void print_line_separator(bool inverted)
print a line separator with board matching background colors
A class representing the chess board.
bool is_promotion_needed(coordinates coord)
check if a promotion is needed
std::vector< piece * > black_pieces
void canonical_print()
print the board in canonical form
bool is_check(bool white_king)
check if the selected player is in check state
bool is_king_castling_legal(bool white_move)
check if the king-side castling move is legal, without checking it in regards to king check state
bool is_checkmate_or_pat(bool white_move)
check if the other player can move without being in a check state
bool is_legal(coordinates move_from, coordinates move_to, bool white_move)
Check if a move is legal, without checking it in regards to king check state.
void print()
print the board
bool is_queen_castling_legal(bool white_move)
check if the queen-side castling move is legal, without checking it in regards to king check state
void move(coordinates move_from, coordinates move_to)
Move a piece from one position to another, supposing that the move is legal.
void king_castle(bool white_move)
perform the king-side castling move
void erase_piece(coordinates coord)
Erase a piece from its corresponding vector according to its coordinates.
bool is_en_passant_legal(coordinates move_from, coordinates move_to, bool white_move)
bool last_move_en_passant_eligible
void put(piece *to_put)
put a piece onto the board according to its coordinates
void promote(coordinates to_promote, piece_type new_type)
Perform a promotion on the specified coordinates. Don't check anything.
coordinates get_king_coord(bool white_king)
retrieve the king coordinates
void queen_castle(bool white_move)
perform the queen-side castling move
int without_attack_or_pawn_counter
std::vector< piece * > white_pieces
a class representing coordinates
int get_x()
a function to get the x-axis attribute
int get_y()
a function to get the y-axis attribute
void move(coordinates move_to)
change the coordinate values to move the associated piece
a generic piece class. white is a boolean indicating the piece's color. legals is a vector indicating...
bool is_possible(coordinates dest)
verify if a move is within piece range
bool get_color()
retrieve the piece's color
virtual void move(coordinates dest, bool debug_info)
called to move the piece
virtual bool is_possible_attack(coordinates dest)
verify if a move is within piece attack range
piece_type get_type()
retrieve the piece's type
coordinates get_coord()
retrieve the piece's coordinates
virtual void canonical_print_piece()
print the piece to the standard output in canonical form
virtual void print_piece()
print the piece to the standard output
virtual void needed_space(coordinates dest, std::vector< coordinates > *to_calculate)
calculate the space needed for the piece to move
#define BACKGROUND_COLOR2
#define BACKGROUND_COLOR1
piece_type
Represent a piece type. Undefined for default piece.
void terminal_reset_all()
reset all terminal attributes
void terminal_set_background_color(terminal_color color)
set the terminal background color to the input
void terminal_set_text_color(terminal_color color)
set the terminal font color to the input