Added moveList to Board class + some helper functions
This commit is contained in:
1 parent
d0d7af4a79
commit
076ce9b904
4 files changed
+24
-4
No files matched your search
@@ -212,3 +212,13 @@ void Board::PrintBoard() {
|
|||||||
std::cout << "+---+---+---+---+---+---+---+---+\n";
|
std::cout << "+---+---+---+---+---+---+---+---+\n";
|
||||||
std::cout << " a b c d e f g h\n\n";
|
std::cout << " a b c d e f g h\n\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Board::AddMove(Move move) {
|
||||||
|
moveList.push_back(move);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Board::ListMoves() {
|
||||||
|
for (Move move : moveList) {
|
||||||
|
move.PrintMove();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,8 +2,12 @@
|
|||||||
#include <array>
|
#include <array>
|
||||||
#include "bitboards.h"
|
#include "bitboards.h"
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
#include "movegen.h"
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
class Board {
|
class Board {
|
||||||
|
private:
|
||||||
|
std::vector<Move> moveList;
|
||||||
public:
|
public:
|
||||||
std::array<Bitboard, 6> pieces;
|
std::array<Bitboard, 6> pieces;
|
||||||
std::array<Bitboard, 2> colors;
|
std::array<Bitboard, 2> colors;
|
||||||
@@ -13,6 +17,8 @@ public:
|
|||||||
int halfMoves = 0;
|
int halfMoves = 0;
|
||||||
int fullMoves = 0;
|
int fullMoves = 0;
|
||||||
|
|
||||||
|
Move lastMove;
|
||||||
|
|
||||||
std::array<bool, 4> castlingRights = { false, false, false, false };
|
std::array<bool, 4> castlingRights = { false, false, false, false };
|
||||||
Bitboard enPassantTarget;
|
Bitboard enPassantTarget;
|
||||||
|
|
||||||
@@ -20,4 +26,6 @@ public:
|
|||||||
void Reset();
|
void Reset();
|
||||||
void SetByFen(const char* fen);
|
void SetByFen(const char* fen);
|
||||||
void PrintBoard();
|
void PrintBoard();
|
||||||
|
void AddMove(Move move);
|
||||||
|
void ListMoves();
|
||||||
};
|
};
|
||||||
+2
-2
@@ -16,8 +16,8 @@ static Bitboard notHfile = ~files[H];
|
|||||||
static Bitboard notABfile = notAfile & ~files[B];
|
static Bitboard notABfile = notAfile & ~files[B];
|
||||||
static Bitboard notHGfile = notHfile & ~files[G];
|
static Bitboard notHGfile = notHfile & ~files[G];
|
||||||
|
|
||||||
void doMove(Move move) {
|
void Move::PrintMove() {
|
||||||
|
std::cout << squareCoords[moveFrom] << squareCoords[moveTo] << '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
Bitboard maskPawnAttacks(int side, int square) {
|
Bitboard maskPawnAttacks(int side, int square) {
|
||||||
|
|||||||
+4
-2
@@ -6,11 +6,13 @@ public:
|
|||||||
SQUARE moveFrom;
|
SQUARE moveFrom;
|
||||||
SQUARE moveTo;
|
SQUARE moveTo;
|
||||||
|
|
||||||
|
Move(){}
|
||||||
|
|
||||||
Move(const SQUARE from, const SQUARE to)
|
Move(const SQUARE from, const SQUARE to)
|
||||||
: moveFrom(from), moveTo(to) {}
|
: moveFrom(from), moveTo(to) {}
|
||||||
};
|
|
||||||
|
|
||||||
void doMove(Move move);
|
void PrintMove();
|
||||||
|
};
|
||||||
|
|
||||||
// bishop relevant occupancy bit count
|
// bishop relevant occupancy bit count
|
||||||
constexpr int bishopRelevantBits[64] = {
|
constexpr int bishopRelevantBits[64] = {
|
||||||
|
|||||||
Reference in new issue
Block a user