fmt: reformatted code, changed some function signatures, fairly minor

This commit is contained in:
A.M. Rowsell 2025-08-29 04:17:16 -04:00
commit 21fae88bdb
Signed by untrusted user who does not match committer: amr
GPG key ID: E0879EDBDB0CA7B1
5 changed files with 216 additions and 50 deletions

View file

@ -9,39 +9,37 @@
#ifndef BOARD_HPP
#define BOARD_HPP
#include <vector>
#include <memory>
#include <cstdint>
#include <memory>
#include <string>
#include <vector>
#include "Piece.hpp"
// why do I have to forward declare all these?!
class Piece;
enum Players {
PL_WHITE, PL_BLACK
};
enum Players { PL_WHITE, PL_BLACK };
struct Square;
class Board {
private:
friend class Piece;
Players playerTurn;
public:
// this should be protected, but even when Piece is declared as a friend,
// accessing it in Piece.cpp threw an error
std::vector<std::vector<std::unique_ptr<Piece>>> boardGrid;
Board();
virtual ~Board();
void setupInitialPosition();
Piece *getPieceAt(Square square);
void movePiece(Square from, Square to);
int setupFromFEN(std::string strFEN);
bool isInBounds(Square square) const;
bool isEmpty(Square square) const;
uint64_t serialBoard = 0xFFFF00000000FFFF; // opening position
void deserializeBoard(uint64_t incomingBoard);
private:
friend class Piece;
Players playerTurn;
public:
// this should be protected, but even when Piece is declared as a friend,
// accessing it in Piece.cpp threw an error
std::vector<std::vector<std::unique_ptr<Piece>>> boardGrid;
Board();
virtual ~Board();
void setupInitialPosition();
std::unique_ptr<Piece> &getPieceAt(Square square);
void movePiece(Square from, Square to);
int setupFromFEN(std::string strFEN);
bool isInBounds(Square square) const;
bool isEmpty(Square square) const;
uint64_t serialBoard = 0xFFFF00000000FFFF; // opening position
void deserializeBoard(uint64_t incomingBoard);
};
#endif // BOARD_HPP

View file

@ -68,7 +68,7 @@ class Piece {
Piece(PieceColour pColour) : colour(pColour) {
}
virtual ~Piece();
virtual std::vector<Move> getLegalMoves(const Square &from, const Board &board) const;
virtual std::vector<Move> getLegalMoves(const Square &from, Board &board) const;
PieceColour getColour() const {
return colour;
@ -101,9 +101,9 @@ class King : public Piece {
pieceSymbol = 'K';
pieceType = KING;
}
virtual std::vector<Move> getLegalMoves(const Square &from, const Board &board) const override;
virtual std::vector<Move> getLegalMoves(const Square &from, Board &board) const override;
bool checkForCheck() const;
bool checkForCheck(Board &board) const;
bool checkForCastle(enum CastleSide side) const {
if(side == KINGSIDE)
@ -130,7 +130,7 @@ class Rook : public Piece {
pieceSymbol = 'R';
pieceType = ROOK;
}
virtual std::vector<Move> getLegalMoves(const Square &from, const Board &board) const override;
virtual std::vector<Move> getLegalMoves(const Square &from, Board &board) const override;
};
class Queen : public Piece {
@ -142,7 +142,7 @@ class Queen : public Piece {
pieceSymbol = 'Q';
pieceType = QUEEN;
}
virtual std::vector<Move> getLegalMoves(const Square &from, const Board &board) const override;
virtual std::vector<Move> getLegalMoves(const Square &from, Board &board) const override;
};
class Knight : public Piece {
@ -154,7 +154,7 @@ class Knight : public Piece {
pieceSymbol = 'N';
pieceType = KNIGHT;
}
virtual std::vector<Move> getLegalMoves(const Square &from, const Board &board) const override;
virtual std::vector<Move> getLegalMoves(const Square &from, Board &board) const override;
};
class Bishop : public Piece {
@ -166,7 +166,7 @@ class Bishop : public Piece {
pieceSymbol = 'B';
pieceType = BISHOP;
}
virtual std::vector<Move> getLegalMoves(const Square &from, const Board &board) const override;
virtual std::vector<Move> getLegalMoves(const Square &from, Board &board) const override;
};
class Pawn : public Piece {
@ -178,7 +178,7 @@ class Pawn : public Piece {
pieceSymbol = 'P';
pieceType = PAWN;
}
virtual std::vector<Move> getLegalMoves(const Square &from, const Board &board) const override;
virtual std::vector<Move> getLegalMoves(const Square &from, Board &board) const override;
};
#endif // PIECE_HPP