diff options
| -rw-r--r-- | src/bot.cpp | 2 | ||||
| -rw-r--r-- | src/bot.hpp | 2 | ||||
| -rw-r--r-- | src/moves.cpp | 7 | ||||
| -rw-r--r-- | src/opening_book.cpp | 0 | ||||
| -rw-r--r-- | src/opening_book.hpp | 24 |
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_ */ |
