Implement board printing

This commit is contained in:
Quinten Kock 2020-06-15 05:48:17 +02:00
parent 72424baa47
commit e19995a0f4
2 changed files with 20 additions and 8 deletions

View File

@ -14,4 +14,5 @@ void loop() {
Serial.println(F("hello")); Serial.println(F("hello"));
delay(1000); delay(1000);
Serial.println(b.get_zobrist()); Serial.println(b.get_zobrist());
b.print();
} }

27
Board.h
View File

@ -7,6 +7,16 @@ class Board {
public: public:
Board(); Board();
void print() {
for(int i = 7; i >= 0; i--) {
for(int j = 0; j < 16; j++) {
Serial.print(field[i*16 + j], HEX);
Serial.print(" ");
}
Serial.println();
}
}
unsigned long get_zobrist() { unsigned long get_zobrist() {
long* addr = (long*) &field[PTR_ZOBRIST]; long* addr = (long*) &field[PTR_ZOBRIST];
return *addr; return *addr;
@ -14,14 +24,14 @@ class Board {
private: private:
byte field[128] = { byte field[128] = {
B_ROOK, B_KNGT, B_BSHP, B_QUEN, B_KING, B_BSHP, B_KNGT, B_ROOK, 0, 0, 0, 0, 0, 0, 0, 0,
B_PAWN, B_PAWN, B_PAWN, B_PAWN, B_PAWN, B_PAWN, B_PAWN, B_PAWN, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
W_PAWN, W_PAWN, W_PAWN, W_PAWN, W_PAWN, W_PAWN, W_PAWN, W_PAWN, 0, 0, 0, 0, 0, 0, 0, 0,
W_ROOK, W_KNGT, W_BSHP, W_QUEN, W_KING, W_BSHP, W_KNGT, W_ROOK, 0, 0, 0, 0, 0, 0, 0, 0, W_ROOK, W_KNGT, W_BSHP, W_QUEN, W_KING, W_BSHP, W_KNGT, W_ROOK, 0, 0, 0, 0, 0, 0, 0, 0,
W_PAWN, W_PAWN, W_PAWN, W_PAWN, W_PAWN, W_PAWN, W_PAWN, W_PAWN, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
B_PAWN, B_PAWN, B_PAWN, B_PAWN, B_PAWN, B_PAWN, B_PAWN, B_PAWN, 0, 0, 0, 0, 0, 0, 0, 0,
B_ROOK, B_KNGT, B_BSHP, B_QUEN, B_KING, B_BSHP, B_KNGT, B_ROOK, 0, 0, 0, 0, 0, 0, 0, 0,
}; };
const byte PTR_SIDE_AND_CASTLERIGHT = 0x08; //byte (1=side, 2,4=white castle, 8,16=black) const byte PTR_SIDE_AND_CASTLERIGHT = 0x08; //byte (1=side, 2,4=white castle, 8,16=black)
@ -71,9 +81,10 @@ Board::Board() {
} }
struct unmake { struct Unmake {
byte sq_from; byte sq_from;
byte sq_to; byte sq_to;
byte enpassant; byte enpassant;
};
#endif #endif