safeDropMajorPiece.h Source File

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
safeDropMajorPiece.h
Go to the documentation of this file.
1 #ifndef OSL_SAFE_DROP_MAJOR_PIECE_H
2 #define OSL_SAFE_DROP_MAJOR_PIECE_H
3 #include "osl/state/numEffectState.h"
4 #include "osl/move_action/store.h"
5 #include "osl/container/moveVector.h"
6
7 namespace osl
8 {
9 namespace move_generator
10 {
11 template <Player P>
12 struct SafeDropMajorPiece
13 {
14 template <class Action>
15 static void generate(const NumEffectState& state, Action& action)
16 {
17 const bool has_bishop = state.template hasPieceOnStand<BISHOP>(P);
18 const bool has_rook = state.template hasPieceOnStand<ROOK>(P);
19
20 if (!has_rook && !has_bishop)
21 return;
22
23 int start_y;
24 if (P == BLACK)
25 start_y = 1;
26 else
27 start_y = 7;
28 for (int x = 1; x <= 9; x++)
29 {
30 for (int y = start_y; y < start_y + 3; y++)
31 {
32 Square position(x, y);
33 if (state.pieceOnBoard(position).isEmpty()
34 && !state.hasEffectAt(alt(P), position))
35 {
36 if (has_rook)
37 {
38 action.dropMove(position, ROOK, P);
39 }
40 if (has_bishop)
41 {
42 action.dropMove(position, BISHOP, P);
43 }
44 }
45 }
46 }
47 }
48 template <size_t Capacity>
49 static void generateMoves(const NumEffectState& state,
50 FixedCapacityVector<Move,Capacity>& out)
51 {
52 move_action::Store store(out);
53 generate(state, store);
54 }
55 };
56 }
57 } // namespace osl
58
59 #endif /* _GENERATE_SAFE_DROP_MAJOR_PIECE_H */
60 // ;;; Local Variables:
61 // ;;; mode:c++
62 // ;;; c-basic-offset:2
63 // ;;; End: