-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreversimove.h
52 lines (35 loc) · 914 Bytes
/
reversimove.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
41
42
43
44
45
46
47
48
49
50
51
52
#ifndef REVERSIMOVE_H
#define REVERSIMOVE_H
#include <boost/shared_ptr.hpp>
namespace ribi {
namespace reversi {
struct Move
{
virtual ~Move() noexcept {}
///Create a Move from a std::string
///Returns a nullptr if the Move cannot be parsed
///
///Notation:
///- x,y -> MovePlacePiece
///- [empty] -> MovePass
static boost::shared_ptr<Move> Parse(const std::string& s) noexcept;
virtual std::string ToStr() const noexcept = 0;
};
struct MovePlacePiece : public Move
{
MovePlacePiece(const int x, const int y) : m_x(x), m_y(y) {}
int GetX() const noexcept { return m_x; }
int GetY() const noexcept { return m_y; }
std::string ToStr() const noexcept;
private:
const int m_x;
const int m_y;
};
struct MovePass : public Move
{
MovePass() {}
std::string ToStr() const noexcept { return "pass"; }
};
} //~namespace reversi
} //~namespace ribi
#endif // REVERSIMOVE_H