aboutsummaryrefslogtreecommitdiff
path: root/src/moves.cpp
diff options
context:
space:
mode:
authorAdam <adammegarules1@gmail.com>2026-07-28 09:43:30 +0200
committerAdam <adammegarules1@gmail.com>2026-07-28 09:43:30 +0200
commitca5e947269608757a1af5295f5c77958de341fc3 (patch)
treed2e0fd2d5937a7ed3144289d6f85b86b1a0d1967 /src/moves.cpp
parentbb42f7d438c088b18e953e38cb07d0cdf25f749a (diff)
making bot do check and add knight table
Diffstat (limited to 'src/moves.cpp')
-rw-r--r--src/moves.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/moves.cpp b/src/moves.cpp
index 5401e8b..d7df595 100644
--- a/src/moves.cpp
+++ b/src/moves.cpp
@@ -123,6 +123,36 @@ std::vector<Move> GetPseudoLegalMoves(Game *b) {
return moves;
}
+bool IsSquareAttacked(Game *board, Position square, bool white) {
+ Game temp = *board;
+
+ // Generate moves for the attacking side
+ temp.turn = white;
+
+ auto moves = GetPseudoLegalMoves(&temp);
+
+ for (const Move &move : moves) {
+ if (move.To == square)
+ return true;
+ }
+
+ return false;
+}
+bool IsPieceTypeAttacked(Game *board, PieceType type, bool white) {
+ Game temp = *board;
+
+ // Generate moves for the attacking side
+ temp.turn = white;
+
+ auto moves = GetPseudoLegalMoves(&temp);
+
+ for (const Move &move : moves) {
+ if (temp.pieces[PositionToIndex(move.To)].type == type)
+ return true;
+ }
+
+ return false;
+}
std::vector<Move> GetLegalMoves(Game *b) {
std::vector<Move> moves = GetPseudoLegalMoves(b);
std::vector<Move> legalMove;