ntesukiMove.h Source File

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
ntesukiMove.h
Go to the documentation of this file.
1 /* ntesukiMove.h
2 */
3 #ifndef _NTESUKIMOVE_H
4 #define _NTESUKIMOVE_H
5
6 #include "osl/move.h"
7 #include "osl/ntesuki/ntesukiExceptions.h"
8
9 namespace osl
10 {
11 namespace ntesuki
12 {
18 class NtesukiMove
19 {
20 enum Flags
21 {
22 NONE = 0,
23 /* 2^0 */
24 CHECK_FLAG = 1,
25 /* 2^1 */
26 PAWN_DROP_CHECKMATE_FLAG = 2,
27 /* 2^2 */
28 /* 4 not used */
29 /* 2^3 */
30 IMMEDIATE_CHECKMATE = 8,
31 /* 2^4 */
32 TO_OLDER_CHILD = 16,
33 /* 2^5 */
34 NOPROMOTE = 32,
35 /* 2^6 */
36 INTERPOSE = 64,
37 /* 2^7 */
38 ATTACK_FLAG = 128,
39 /* 2^8 */
40 BY_SIMULATION = 256,
41 /* 2^9 */
42 LAME_LONG = 512,
43 /* 2^10 */
44 /* 2^11 */
45 /* 2^12 */
46 /* 2^13 */
47 /* 2^14 */
48 /* 2^15 */
49 WHITE_SHIFT = 4,
50 IS_SUCCESS_SHIFT = 16,
51 /* 16-19 BLACK SUCCESS */
52 IS_SUCCESS_BLACK_SHIFT = IS_SUCCESS_SHIFT,
53 /* 20-23 WHITE SUCCESS */
54 IS_SUCCESS_WHITE_SHIFT = IS_SUCCESS_SHIFT + WHITE_SHIFT,
55 IS_SUCCESS_BLACK_BASE = 1 << IS_SUCCESS_BLACK_SHIFT,
56 IS_SUCCESS_WHITE_BASE = 1 << IS_SUCCESS_WHITE_SHIFT,
57 IS_SUCCESS_BLACK_MASK = 0xf * IS_SUCCESS_BLACK_BASE,
58 IS_SUCCESS_WHITE_MASK = 0xf * IS_SUCCESS_WHITE_BASE,
59 IS_FAIL_SHIFT = 24,
60 /* 24-27 BLACK FAIL */
61 IS_FAIL_BLACK_SHIFT = IS_FAIL_SHIFT,
62 /* 28-31 WHITE FAIL */
63 IS_FAIL_WHITE_SHIFT = IS_FAIL_SHIFT + WHITE_SHIFT,
64 IS_FAIL_BLACK_BASE = 1 << IS_FAIL_SHIFT,
65 IS_FAIL_WHITE_BASE = 1 << (IS_FAIL_SHIFT + WHITE_SHIFT),
66 IS_FAIL_BLACK_MASK = 0xf * IS_FAIL_BLACK_BASE,
67 IS_FAIL_WHITE_MASK = 0xfLL * IS_FAIL_WHITE_BASE,
68 };
69
70 static std::string FlagsStr[];
71 template <Player P>
72 int is_success_flag(int pass_left) const;
73 template <Player P>
74 int is_fail_flag(int pass_left) const;
75
76 osl::Move move;
77 int flags;
78 int order;
79 public:
80 unsigned short h_a_proof, h_a_disproof; // 4 byte
81 unsigned short h_d_proof, h_d_disproof; // 4 byte
82
83 public:
84 NtesukiMove();
85 NtesukiMove(osl::Move m);
86 NtesukiMove(osl::Move m, Flags f);
87 NtesukiMove(const NtesukiMove&);
88 ~NtesukiMove();
89 NtesukiMove operator=(const NtesukiMove&);
90
91 /* static methods */
92 static NtesukiMove INVALID();
93
94 /* about the state of the node
95 */
96 /* if it is a check move */
97 void setCheck();
98 bool isCheck() const;
99
100 /* if it is a check move */
101 void setOrder(int o);
102 int getOrder() const;
103
104 /* interpose */
105 void setInterpose();
106 bool isInterpose() const;
107
108 /* long move with no specific meaning */
109 void setLameLong();
110 bool isLameLong() const;
111
112 /* by simulation */
113 void setBySimulation();
114 bool isBySimulation() const;
115
116 /* nopromote */
117 void setNoPromote();
118 bool isNoPromote() const;
119
120 /* if it is a move to an child with less depth */
121 void setToOld();
122 bool isToOld() const;
123
124 /* if it is a immidiate checkmate move */
125 template<Player P>
126 void setImmediateCheckmate();
127 bool isImmediateCheckmate() const;
128
129 /* if it is a success/fail move */
130 template<Player P>
131 void setCheckmateSuccess(int pass_left);
132 template<Player P>
133 bool isCheckmateSuccess(int pass_left) const;
134 bool isCheckmateSuccessSlow(Player P, int pass_left) const;
135
136 template<Player P>
137 void setCheckmateFail(int pass_left);
138 template<Player P>
139 bool isCheckmateFail(int pass_left) const;
140 bool isCheckmateFailSlow(Player P, int pass_left) const;
141
142 /* if it is a pawn drop checkmate move */
143 void setPawnDropCheckmate();
144 bool isPawnDropCheckmate() const;
145
146 /* estimates used before the node after the move is expanded */
147 void setHEstimates(unsigned short p_a, unsigned short d_a,
148 unsigned short p_d, unsigned short d_d);
149 void setCEstimates(unsigned short p, unsigned short d);
150
151 /* about the move itself */
152 bool isValid() const;
153 bool isInvalid() const;
154 bool isNormal() const;
155 bool isPass() const;
156 bool isDrop() const;
157 Square to() const;
158 Ptype ptype() const;
159 Move getMove() const;
160
161 /* equality, only the equality of the move is checked
162 * (the flags are not considered) */
163 bool operator==(const NtesukiMove& rhs) const;
164 bool operator!=(const NtesukiMove& rhs) const;
165
166 /* output to stream */
167 void flagsToStream(std::ostream& os) const;
168 friend std::ostream& operator<<(std::ostream& os, const NtesukiMove& move);
169 };
170
171 }// ntesuki
172 }// osl
173 #endif /* _NTESUKIMOVE_H */
174 // ;;; Local Variables:
175 // ;;; mode:c++
176 // ;;; c-basic-offset:2
177 // ;;; coding:utf-8
178 // ;;; End: