Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uninline needPawnPromotion function #131

Merged
merged 1 commit into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion engine/src/generate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ namespace wisdom
appendMove (knight_move);
}

auto
auto
eligibleEnPassantColumn (const Board& board, int row, int column, Color who)
-> optional<int>
{
Expand Down Expand Up @@ -581,4 +581,19 @@ namespace wisdom
return non_checks;
}

auto
needPawnPromotion (int row, Color who)
-> bool
{
assert (isColorValid (who));
switch (who)
{
case Color::White:
return 0 == row;
case Color::Black:
return 7 == row;
default:
throw Error { "Invalid color in needPawnPromotion()" };
}
}
}
16 changes: 2 additions & 14 deletions engine/src/generate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,9 @@ namespace wisdom
generateLegalMoves (const Board& board, Color who)
-> MoveList;

[[nodiscard]] inline auto
[[nodiscard]] auto
needPawnPromotion (int row, Color who)
-> bool
{
assert (isColorValid (who));
switch (who)
{
case Color::White:
return 0 == row;
case Color::Black:
return 7 == row;
default:
throw Error { "Invalid color in needPawnPromotion()" };
}
}
-> bool;

// Return en passant column if the board is the player is eligible.
[[nodiscard]] auto
Expand Down
Loading