Chess
Classes | Typedefs | Enumerations | Functions
piece.h File Reference

Finds possible moves given a Piece. More...

#include <SDL2/SDL.h>
#include <SDL_image.h>
#include <optional>
#include <string>
#include <vector>
Include dependency graph for piece.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  Piece
 Class structure for the pieces that fill a game state's board. More...
 

Typedefs

using FuncPtr = void(*)(const Piece &piece, std::vector< int > &possible_moves, const Chessboard &chessboard)
 Simplifies function pointer syntax for functions filling a vector possible_moves.
 

Enumerations

enum  Type {
  PAWN, KNIGHT, BISHOP, ROOK,
  KING, QUEEN
}
 

Functions

void test_pawn (const Piece &piece, std::vector< int > &possible_moves, const Chessboard &chessboard)
 
void test_white_pawn (const Piece &piece, std::vector< int > &possible_moves, const Chessboard &chessboard)
 
void test_black_pawn (const Piece &piece, std::vector< int > &possible_moves, const Chessboard &chessboard)
 
void test_rook (const Piece &piece, std::vector< int > &possible_moves, const Chessboard &chessboard)
 
void test_bishop (const Piece &piece, std::vector< int > &possible_moves, const Chessboard &chessboard)
 
void test_knight (const Piece &piece, std::vector< int > &possible_moves, const Chessboard &chessboard)
 
void test_queen (const Piece &piece, std::vector< int > &possible_moves, const Chessboard &chessboard)
 
void test_king (const Piece &piece, std::vector< int > &possible_moves, const Chessboard &chessboard)
 

Detailed Description

Finds possible moves given a Piece.

The Piece class is used to store data like the pos and type of each piece. It is also used to find the possible moves for a piece. Each piece has a different function for this, and the pointers to these functions are stored in a vector to allow for constant time lookup.