dev: started to write Board constructor, added all derived Pieces
This commit is contained in:
parent
ba27097ced
commit
ea62d03680
3 changed files with 85 additions and 18 deletions
17
Piece.cpp
17
Piece.cpp
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
/*
|
||||
* File: Piece.cpp
|
||||
* Author: amr
|
||||
*
|
||||
*
|
||||
* Created on July 30, 2025, 9:21 PM
|
||||
*/
|
||||
|
||||
|
|
@ -24,12 +24,22 @@ std::vector<Move> Piece::getLegalMoves(const Square &from, const Board &board) c
|
|||
|
||||
std::vector<Move> King::getLegalMoves(const Square &from, const Board &board) const {
|
||||
std::vector<Move> moveList;
|
||||
const int directions[8][2] = {
|
||||
{-1, 0}, // Up
|
||||
{-1, -1}, // up-left
|
||||
{-1, 1}, // up-right
|
||||
{1, 0}, // Down
|
||||
{1, -1}, // down-left
|
||||
{1, 1}, // down-right
|
||||
{0, -1}, // Left
|
||||
{0, 1} // Right
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
std::vector<Move> Rook::getLegalMoves(const Square &from, const Board &board) const {
|
||||
std::vector<Move> moveList;
|
||||
const int directions[8][2] = {
|
||||
const int directions[4][2] = {
|
||||
{-1, 0}, // Up
|
||||
{1, 0}, // Down
|
||||
{0, -1}, // Left
|
||||
|
|
@ -58,6 +68,5 @@ std::vector<Move> Rook::getLegalMoves(const Square &from, const Board &board) co
|
|||
}
|
||||
}
|
||||
|
||||
// calculate legal moves somehow
|
||||
return moveList;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue