aboutsummaryrefslogtreecommitdiff
path: root/src/bot.cpp
diff options
context:
space:
mode:
authorAdam <adammegarules1@gmail.com>2026-08-17 15:22:37 +0200
committerAdam <adammegarules1@gmail.com>2026-08-17 15:22:37 +0200
commitad04f16e478357633c08174e844c8756f7892a32 (patch)
tree6e1ca98dfa67584e86346bfe36c5d98ff6d59b3c /src/bot.cpp
parent26c0c08b1c4fb302db55355bd49181c8740b7ee6 (diff)
refactor(board): refactoring move generation code into better and nice way + adding debug command moves
Diffstat (limited to 'src/bot.cpp')
-rw-r--r--src/bot.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/bot.cpp b/src/bot.cpp
index b09a704..7b937bd 100644
--- a/src/bot.cpp
+++ b/src/bot.cpp
@@ -84,10 +84,10 @@ static int ScoreMove(const Game *board, const uint16_t &move,
return score;
}
-static std::vector<uint16_t> GetSortedLegalMoves(Game *g,
- bool generateQuietMoves,
- const uint16_t *bestMove) {
- auto moves = GetLegalMoves(g, generateQuietMoves);
+static std::vector<uint16_t>
+GetSortedLegalMoves(Game *g, const move_generate_options &options,
+ const uint16_t *bestMove) {
+ auto moves = GetLegalMoves(g, options);
std::ranges::sort(moves, [&](const uint16_t &a, const uint16_t &c) {
return ScoreMove(g, a, bestMove) > ScoreMove(g, c, bestMove);
});
@@ -134,7 +134,7 @@ static int quiescenceSearch(Game *b, int qdepth, int alpha, int beta, int ply) {
}
alpha = std::max(alpha, standPat);
- auto moves = GetSortedLegalMoves(b, false, nullptr);
+ auto moves = GetSortedLegalMoves(b, CAPTUARES_ONLY, nullptr);
for (uint16_t move : moves) {
Undo undo = MakeMove(move, b);
@@ -200,10 +200,10 @@ static int search(int depth, Game *b, int alpha, int beta, int ply) {
}
uint16_t ttBestMove = entry != nullptr ? entry->bestMove : uint16_t{};
- std::vector<uint16_t> moves = GetSortedLegalMoves(b, true, &ttBestMove);
+ std::vector<uint16_t> moves = GetSortedLegalMoves(b, ALL, &ttBestMove);
if (moves.empty()) {
- if (IsSquareAttacked(b, FindKing(b, b->turn), !b->turn)) {
+ if (IsSquareAttacked(*b, FindKing(*b, b->turn), !b->turn)) {
return -(MATE - ply); // mated
}
return 0; // stalemate
@@ -256,7 +256,7 @@ struct SearchResult {
*/
static SearchResult SearchDepth(Game *b, int depth,
const uint16_t *previousBest) {
- auto moves = GetSortedLegalMoves(b, true, previousBest);
+ auto moves = GetSortedLegalMoves(b, ALL, previousBest);
if (moves.empty()) {
return {
@@ -325,7 +325,7 @@ uint16_t GetBestMove(Game *b, int maxDepth, move_options options) {
bool hasSetSpecialTimeLimit = false;
- auto legalMoves = GetSortedLegalMoves(b, true, nullptr);
+ auto legalMoves = GetSortedLegalMoves(b, ALL, nullptr);
if (legalMoves.empty()) {
assert(false && "GetBestMove called with no legal moves");
return {};