forked from chncwang/FoolGo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheye_set.h
More file actions
59 lines (48 loc) · 1.21 KB
/
eye_set.h
File metadata and controls
59 lines (48 loc) · 1.21 KB
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
53
54
55
56
57
58
59
#ifndef FOOLGO_SRC_PIECE_STRUCTRUE_EYE_SET_H_
#define FOOLGO_SRC_PIECE_STRUCTRUE_EYE_SET_H_
#include <bitset>
#include "../board/position.h"
#include "../def.h"
namespace foolgo {
namespace piece_structure {
template<BoardLen BOARD_LEN>
class EyeSet {
public:
EyeSet() = default;
~EyeSet() = default;
void Copy(const EyeSet &es);
void SetEye(PositionIndex indx, bool v) {
eyes_[indx] = v;
}
void SetRealEye(PositionIndex indx, bool v) {
real_eyes_[indx] = v;
}
bool IsEye(PositionIndex indx) const {
return eyes_[indx];
}
bool IsRealEye(PositionIndex indx) const {
return real_eyes_[indx];
}
PositionIndex RealCount() const {
return real_eyes_.count();
}
std::vector<PositionIndex> GetRealEyes() const {
return util::GetOnePositionIndexes<BoardLenSquare<BOARD_LEN>()>(
real_eyes_);
}
private:
BitSet<BOARD_LEN> eyes_;
BitSet<BOARD_LEN> real_eyes_;
};
template<BoardLen BOARD_LEN>
bool IsFakeEye(const EyeSet<BOARD_LEN> &eyeset, PositionIndex indx) {
return eyeset.IsEye(indx) && !eyeset.IsRealEye(indx);
}
template<BoardLen BOARD_LEN>
inline void EyeSet<BOARD_LEN>::Copy(const EyeSet &es) {
eyes_ = es.eyes_;
real_eyes_ = es.real_eyes_;
}
}
}
#endif