stickfosh/cpp/src/board.hpp
Karma Riuk 84c3af2bb1
Some checks failed
pre-release / Pre Release (push) Has been cancelled
tagged-release / Tagged Release (push) Has been cancelled
fully support FEN strings now
2025-02-02 23:05:42 +01:00

36 lines
796 B
C++

#pragma once
#include "coords.hpp"
#include "move.hpp"
#include "pieces/piece.hpp"
#include <string>
struct Board {
private:
int8_t get_king_of(int8_t colour) const;
public:
int8_t squares[64] = {Piece::None};
bool white_to_play = true;
int8_t w_castle_rights = CastleSide::NeitherSide;
int8_t b_castle_rights = CastleSide::NeitherSide;
int8_t en_passant_target = -1;
uint8_t n_half_moves = 0;
uint8_t n_full_moves = 0;
static Board setup_fen_position(std::string fen);
Board make_move(Move) const;
std::string to_fen() const;
bool is_check_for(int8_t) const;
int8_t colour_at(int8_t idx) const {
return squares[idx] & 0b11000;
}
int8_t colour_at(Coords xy) const {
return colour_at(xy.to_index());
}
};