-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathField.h
40 lines (36 loc) · 1.38 KB
/
Field.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#pragma once
#include <iostream>
#include <vector>
#include "GlobalBoard.h"
class GameException {};
class Field
{
private:
GlobalBoard* board;
Cell turn;
public:
Field();
~Field();
// Warning: there are no safety checks in most methods
void move(const GlobalCoord& coord);
void move(const Coord& global, Coord& local);
void move(size_t by, size_t bx, size_t y, size_t x);
void revert();
bool isLegalMove(const GlobalCoord& coord) const;
bool isLegalMove(const Coord& global, const Coord& local) const;
bool isLegalMove(size_t by, size_t bx, size_t y, size_t x) const;
Cell get(const GlobalCoord& coord) const;
Cell get(const Coord& global, const Coord& local) const;
Cell get(size_t by, size_t bx, size_t y, size_t x) const;
Cell getTurn() const;
Cell getWinner() const;
Cell getWinner(const size_t by, const size_t bx) const;
// Will return Coord(-1, -1) if next board is any
Coord getNextBoard() const;
// Heavy on time and memory, better to avoid overusing these in engine logic:
// getEmptyCells will return valid moves by (y, x) on every board, where by = i / 3, bx = i % 3
std::vector <std::vector <Coord>> getEmptyCells() const;
// getValidMoves will return valid moves by full coordinate in a single vector
std::vector <GlobalCoord> getValidMoves() const;
friend std::ostream& operator << (std::ostream& out, Field& field);
};