Debian Codegraph @

full/osl/ntesuki/move_generator/captureEffectToAroundKing8.h

raw
1 #ifndef _GENERATE_CAPTURE_EFFECT_TO_AROUND_KING8_H
2 #define _GENERATE_CAPTURE_EFFECT_TO_AROUND_KING8_H
3 #include "osl/move_generator/pieceOnBoard.h"
4 #include "osl/move_action/captureFrom.h"
5 #include "osl/move_action/store.h"
6 #include "osl/centering3x3.h"
7 #include "osl/state/numEffectState.h"
8 #include "osl/container/moveVector.h"
9
10 namespace osl
11 {
12 namespace move_generator
13 {
14 /**
15 * Capture pieces that has effect to squares around King and to the King.
16 * - TODO should be Capture Effecto To Around King 9?
17 * - Using centering3x3, i.e. if the King is on the edge,
18 * the area is move towards the center of the board.
19 */
20 template <Player P>
21 struct CaptureEffectToAroundKing8
22 {
23 template <class Action>
24 static void generateTo(const NumEffectState& state,
25 Square p,
26 Action& action)
27 {
28 typedef move_action::CaptureFrom<P, Action>
29 capture_action;
30 capture_action capture(state, action);
31
32 if (p.isEdge()) return;
33 assert(p.isOnBoard());
34
35 state.template forEachEffect<PlayerTraits<P>::opponent,
36 capture_action>(p, capture);
37 }
38
39 static void generate(const NumEffectState& state, MoveVector& moves)
40 {
41 const Square position_king =
42 Centering3x3::adjustCenter(state.template kingSquare<P>());
43 {
44 move_action::Store action(moves);
45 generateTo(state,
46 position_king,
47 action);
48 generateTo(state,
49 position_king + Board_Table.getOffsetForBlack(UL),
50 action);
51 generateTo(state,
52 position_king + Board_Table.getOffsetForBlack(U),
53 action);
54 generateTo(state,
55 position_king + Board_Table.getOffsetForBlack(UR),
56 action);
57 generateTo(state,
58 position_king + Board_Table.getOffsetForBlack(L),
59 action);
60 generateTo(state,
61 position_king + Board_Table.getOffsetForBlack(R),
62 action);
63 generateTo(state,
64 position_king + Board_Table.getOffsetForBlack(DL),
65 action);
66 generateTo(state,
67 position_king + Board_Table.getOffsetForBlack(D),
68 action);
69 generateTo(state,
70 position_king + Board_Table.getOffsetForBlack(DR),
71 action);
72 }
73 moves.unique();
74 }
75
76 };
77 }
78 } // namespace osl
79
80 #endif /* _GENERATE_CAPTURE_EFFECT_TO_AROUND_KING8_H */
81 // ;;; Local Variables:
82 // ;;; mode:c++
83 // ;;; c-basic-offset:2
84 // ;;; End: