extracted coords to its own hpp

This commit is contained in:
Karma Riuk 2025-02-02 20:17:27 +01:00
parent e08dbb913e
commit 8bf164cb05
4 changed files with 21 additions and 12 deletions

View File

@ -4,18 +4,6 @@
#include <string>
struct Coords {
int x, y;
int8_t to_index() const {
return this->y * 8 + this->x;
}
static Coords from_index(int idx) {
return {idx % 8, idx / 8};
}
};
struct Board {
private:
int8_t get_king_of(int8_t colour) const;

19
cpp/src/coords.hpp Normal file
View File

@ -0,0 +1,19 @@
#pragma once
#include <cstdint>
struct Coords {
int x, y;
int8_t to_index() const {
return this->y * 8 + this->x;
}
static Coords from_index(int idx) {
return {idx % 8, idx / 8};
}
bool is_within_bounds() const {
return this->to_index() < 64;
}
};

View File

@ -1,4 +1,5 @@
#include "../board.hpp"
#include "../coords.hpp"
#include "../move.hpp"
#include "piece.hpp"

View File

@ -1,6 +1,7 @@
#include "piece.hpp"
#include "../board.hpp"
#include "../coords.hpp"
std::vector<Move>
keep_only_blocking(const std::vector<Move> candidates, const Board& board) {