aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAdam <adammegarules1@gmail.com>2026-08-01 13:44:57 +0200
committerAdam <adammegarules1@gmail.com>2026-08-01 13:44:57 +0200
commitf56178ec9afdd89b85fc0284bddefa5b3f9515d1 (patch)
tree3cb637768272e89bbc4d0dec31e5eb818c2ce868 /src
parent980ac2bc1ccbe1b8bde626a964464bb018baa466 (diff)
none
Diffstat (limited to 'src')
-rw-r--r--src/bot.cpp2
-rw-r--r--src/bot.hpp2
-rw-r--r--src/moves.cpp7
-rw-r--r--src/opening_book.cpp0
-rw-r--r--src/opening_book.hpp24
5 files changed, 33 insertions, 2 deletions
diff --git a/src/bot.cpp b/src/bot.cpp
index 03636f9..02dfd22 100644
--- a/src/bot.cpp
+++ b/src/bot.cpp
@@ -14,7 +14,7 @@
#include <iterator>
#include <vector>
-constexpr int MAXIMUM_DEPTH = 10;
+constexpr int MAXIMUM_DEPTH = 6;
constexpr int MAXIMUM_TIME_PER_MOVE = 7;
constexpr int Q_DEPTH_LIMIT = 4;
diff --git a/src/bot.hpp b/src/bot.hpp
index 821eb28..c271882 100644
--- a/src/bot.hpp
+++ b/src/bot.hpp
@@ -5,4 +5,4 @@
Move GetBestMove(Game *b, int depth);
-#endif /* SRC_EVALUATE_H_ */
+#endif /* SRC_BOT_H_ */
diff --git a/src/moves.cpp b/src/moves.cpp
index 163bb8c..803538b 100644
--- a/src/moves.cpp
+++ b/src/moves.cpp
@@ -417,6 +417,13 @@ void GenerateCastlingMoves(int from, Game *g, std::vector<Move> &moves) {
bool oneToLeft = g->PieceBitboard & (1ULL << (from - 1));
bool twoToLeft = g->PieceBitboard & (1ULL << (from - 2));
bool threeToLeft = g->PieceBitboard & (1ULL << (from - 3));
+
+ Position kingPosition = FindKing(g, g->turn);
+
+ bool check = IsSquareAttacked(g, kingPosition, !g->turn);
+ if (check) {
+ return;
+ }
if (g->turn) {
// white
if (!oneToRight && !twoToRight && g->whiteCastleKing) {
diff --git a/src/opening_book.cpp b/src/opening_book.cpp
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/opening_book.cpp
diff --git a/src/opening_book.hpp b/src/opening_book.hpp
new file mode 100644
index 0000000..e37e8b3
--- /dev/null
+++ b/src/opening_book.hpp
@@ -0,0 +1,24 @@
+#ifndef SRC_OPENING_BOOK_H_
+#define SRC_OPENING_BOOK_H_
+
+#include "board/board.hpp"
+#include <cstdint>
+#include <string>
+#include <vector>
+struct Polygot_Entry {
+ uint64_t key;
+ uint16_t move;
+ uint16_t weight;
+ uint32_t learn;
+};
+
+class Polyglot_Book {
+public:
+ bool Load(const std::string &filename);
+ bool HasMove(const Game &board) const;
+ Move GetMove(const Game &board) const;
+
+private:
+ std::vector<Polygot_Entry> entries;
+};
+#endif /* SRC_OPENING_BOOK_H_ */