-
Notifications
You must be signed in to change notification settings - Fork 0
/
move.h
47 lines (38 loc) · 954 Bytes
/
move.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
/* Written by Todd Doucet. */
#pragma once
#include <string>
#include "board.h"
class moves
{
public:
struct move { int from, to, hit; };
moves() = default;
move& operator[](int i) { return m[i]; }
move operator[](int i) const { return m[i]; }
int count() const { return cnt; }
void push(move mp) { m[cnt++] = mp; }
move pop() { return m[--cnt]; }
void clear() { cnt = 0; }
private:
move m[4] = {0};
int cnt = 0;
};
class callBack
{
public:
moves m;
int nMoves;
int checkersToPlay;
virtual int callBackF(const board &b) = 0;
virtual ~callBack(){ }
callBack() : nMoves(0), checkersToPlay(0) { }
};
class nullCallBack : public callBack
{
int callBackF(const board &b) { return 0; }
};
std::string moveStr(moves& m);
int plays(const board& b, callBack& callB);
int numMoves(board& b);
int checkersToPlay(board& b);
void applyMove(board& b,const moves& m);