extracted coords to its own hpp
This commit is contained in:
parent
e08dbb913e
commit
8bf164cb05
@ -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
19
cpp/src/coords.hpp
Normal 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;
|
||||
}
|
||||
};
|
@ -1,4 +1,5 @@
|
||||
#include "../board.hpp"
|
||||
#include "../coords.hpp"
|
||||
#include "../move.hpp"
|
||||
#include "piece.hpp"
|
||||
|
||||
|
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user