Move class + full board print function

This commit is contained in:
rektdie committed 2024-03-21 11:57:40 +01:00
1 parent ec8e4cf0a6
commit d0d7af4a79
5 files changed
+57

No files matched your search

+32
View File
@@ -179,4 +179,36 @@ void Board::SetByFen(const char* fen) {
}
occupied = (colors[White] | colors[Black]);
}
void Board::PrintBoard() {
for (int rank = 7; rank >= 0; rank--) {
std::cout << "+---+---+---+---+---+---+---+---+\n";
std::cout << "| ";
for (int file = 0; file < 8; file++) {
int square = rank * 8 + file;
bool pieceSet = false;
for (int i = Pawn; i <= King; i++) {
if ((colors[White] & pieces[i]).IsSet(square)) {
std::cout << PIECE_LETTERS[i * 2 + White] << " | ";
pieceSet = true;
} else if ((colors[Black] & pieces[i]).IsSet(square)) {
std::cout << PIECE_LETTERS[i * 2 + Black] << " | ";
pieceSet = true;
}
}
if (!pieceSet) {
std::cout << " | ";
}
}
std::cout << ' ' << rank + 1 << '\n';
}
std::cout << "+---+---+---+---+---+---+---+---+\n";
std::cout << " a b c d e f g h\n\n";
}
+1
View File
@@ -19,4 +19,5 @@ public:
void Init();
void Reset();
void SetByFen(const char* fen);
void PrintBoard();
};
+4
View File
@@ -16,6 +16,10 @@ static Bitboard notHfile = ~files[H];
static Bitboard notABfile = notAfile & ~files[B];
static Bitboard notHGfile = notHfile & ~files[G];
void doMove(Move move) {
}
Bitboard maskPawnAttacks(int side, int square) {
Bitboard attacks;
Bitboard attacker = Bitboard::GetSquare(square);
+11
View File
@@ -1,6 +1,17 @@
#pragma once
#include "bitboards.h"
struct Move {
public:
SQUARE moveFrom;
SQUARE moveTo;
Move(const SQUARE from, const SQUARE to)
: moveFrom(from), moveTo(to) {}
};
void doMove(Move move);
// bishop relevant occupancy bit count
constexpr int bishopRelevantBits[64] = {
6, 5, 5, 5, 5, 5, 5, 6,
+9
View File
@@ -20,6 +20,15 @@ enum PIECE {
King
};
constexpr std::array<const char, 12> PIECE_LETTERS = {
'P', 'p',
'N', 'n',
'B', 'b',
'R', 'r',
'Q', 'q',
'K', 'k'
};
enum FILES { A, B, C, D, E, F, G, H };
enum RANKS { r_1, r_2, r_3, r_4, r_5, r_6, r_7, r_8 };