diff options
| author | Adam <adammegarules1@gmail.com> | 2026-07-26 19:16:57 +0200 |
|---|---|---|
| committer | Adam <adammegarules1@gmail.com> | 2026-07-26 19:16:57 +0200 |
| commit | 7e8d89f357aaf8d8a6148ef051752dd53eb0285f (patch) | |
| tree | b169dcc4e0bc00bc2bb39c9c4b6ced2d3f518864 /src/moves.cpp | |
| parent | a8b482443dca91f6410a60e9023c6d9dd853b400 (diff) | |
adding repl
Diffstat (limited to 'src/moves.cpp')
| -rw-r--r-- | src/moves.cpp | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/moves.cpp b/src/moves.cpp index 5c8c07e..0059039 100644 --- a/src/moves.cpp +++ b/src/moves.cpp @@ -5,7 +5,7 @@ #include "board.hpp" #include "moves.hpp" -void GeneratePawnMoves(board *b, int from, std::vector<Move> &moves) { +void GeneratePawnMoves(Board *b, int from, std::vector<Move> &moves) { Piece pawn = b->pieces[from]; if (pawn.type != PAWN) { assert(false && "Calling generate pawn moves on non pawn"); @@ -49,7 +49,7 @@ void GeneratePawnMoves(board *b, int from, std::vector<Move> &moves) { // the end } -std::vector<Move> GetLegalMoves(board *b) { +std::vector<Move> GetLegalMoves(Board *b) { std::vector<Move> moves; moves.reserve(50); // almost all position dont have that many moves @@ -93,7 +93,7 @@ Position IndexToPosition(int i) { return {rank, file}; } -void GenerateSlidingMoves(board *b, int from, +void GenerateSlidingMoves(Board *b, int from, const std::array<int, 4> &directions, std::vector<Move> &moves) { for (uint i = 0; i < directions.size(); i++) { @@ -128,7 +128,7 @@ void GenerateSlidingMoves(board *b, int from, }; }; -void GenerateKingMoves(board *b, int from, std::vector<Move> &moves) { +void GenerateKingMoves(Board *b, int from, std::vector<Move> &moves) { if (b->pieces[from].type != KING) { assert(false && "calling generate king moves on non king"); return; @@ -146,9 +146,11 @@ void GenerateKingMoves(board *b, int from, std::vector<Move> &moves) { if (std::abs((next % 8) - (from % 8)) > 1) { continue; }; - if (b->pieces[next].color == b->turn) { - continue; - }; + if (b->pieces[next].type != NONE) { + if (b->pieces[next].color == b->turn) { + continue; + }; + } moves.push_back({IndexToPosition(from), IndexToPosition(next)}); } |
