My Project
escape_.h
Go to the documentation of this file.
1#ifndef OSL_MOVE_GENERATOR_ESCAPE_H
2#define OSL_MOVE_GENERATOR_ESCAPE_H
6#include "osl/basic_type.h"
7
8namespace osl
9{
10 namespace move_generator
11 {
16 template<class Action>
17 class Escape
18 {
19 public:
26 template<Player P,bool CheapOnly>
27 static void generateBlocking(const NumEffectState& state,Piece p,Square to,Square from,Action &action);
34 template<Player P,bool CheapOnly>
35 static void generateBlockingKing(const NumEffectState& state,Piece p,Square from,Action &action);
41 template<Player P>
42 static void generateCaptureKing(const NumEffectState& state,Piece p,Square target,Action& action) {
43 Capture<Action>::template escapeByCapture<P>(state,target,p,action);
44 }
45 template<Player P>
46 static void generateCapture(const NumEffectState& state,Piece p,Square target,Action& action) {
47 Capture<Action>::template escapeByCapture<P>(state,target,p,action);
48 }
49 template<Player P,Ptype Type>
50 static void generateEscape(const NumEffectState& state,Piece p,Action& action,Int2Type<Type>);
51
55 template<Player P,Ptype Type>
56 static void generateEscape(const NumEffectState& state,Piece p,Action& action){
60 if(Type==KING){
61 assert(p.owner()==P && p.ptype()==KING);
63 generatePtype<P,Type>(state,p,action);
64 }
65 else
66 {
67 typedef move_action::NoEffectFilter<P,Action> CheckAction;
68 CheckAction checkAction(state,action,p.square());
70 generatePtype<P,Type>(state,p,
71 checkAction);
72 }
73 }
74
75 public:
76 template<Player P,bool cheapOnly>
77 static void generateKingEscape(const NumEffectState& state,Action& action);
78
82 template<Player P,Ptype Type,bool CheapOnly>
83 static void generateMovesBy(const NumEffectState& state,Piece p,Piece attacker,Action& action);
84 template<Player P,Ptype Type,bool CheapOnly>
85 static void generateMovesBy(const NumEffectState& state,Piece p,Move last_move,Action& action);
86 template<Player P,Ptype Type,bool CheapOnly>
87 static void generateMovesBy(const NumEffectState& state,Piece p,Action& action);
88
93 template<Player P,bool CheapOnly>
94 static void generateMoves(const NumEffectState& state,Piece piece,Piece attacker,Action& action);
95
99 template<Player P,bool shouldPromote,bool CheapOnly>
100 static void generate(const NumEffectState& state,Piece piece,Action& action);
101 };
102
103 template <Player P>
105 {
106 template <class Action>
107 static void generate(const NumEffectState& state, Piece piece, Action& a)
108 {
109 Escape<Action>::template generate<P,true,false>(state, piece, a);
110 }
111 static void generate(const NumEffectState& state, Piece piece, MoveVector& out)
112 {
113 move_action::Store store(out);
114 Escape<move_action::Store>::template generate<P,true,false>(state, piece, store);
115 }
116 template <class Action>
117 static void generateCheap(const NumEffectState& state, Piece piece, Action& a)
118 {
119 Escape<Action>::template generate<P,true,true>(state, piece, a);
120 }
121
122 static void generateCheap(const NumEffectState& state, Piece piece, MoveVector& out)
123 {
124 move_action::Store store(out);
125 Escape<move_action::Store>::template generate<P,true,false>(state, piece, store);
126 }
127
129 template <size_t Capacity>
135 template <size_t Capacity>
141 };
143 {
144 template <class Action>
145 static void generate(const NumEffectState& state, Piece piece, Action& a)
146 {
147 if (state.turn() == BLACK)
148 {
149 Escape<Action>::template generate<BLACK,true,false>(state, piece, a);
150 }
151 else
152 {
153 Escape<Action>::template generate<WHITE,true,false>(state, piece, a);
154 }
155 }
156 };
157
158 } // namespace move_generator
160 {
162 static void generate(const NumEffectState& state, MoveVector& out);
163 static void generateCheap(const NumEffectState& state, MoveVector& out);
164 };
166} // namespace osl
167#endif // OSL_MOVE_GENERATOR_ESCAPE_H
168// ;;; Local Variables:
169// ;;; mode:c++
170// ;;; c-basic-offset:2
171// ;;; End:
圧縮していない moveの表現 .
利きを持つ局面
Ptype ptype() const
Definition basic_type.h:821
const Square square() const
Definition basic_type.h:832
Player owner() const
Definition basic_type.h:963
Player turn() const
利きのないところへ動くためのフィルタ
Definition move_action.h:73
駒を取る手を生成
Definition capture_.h:18
逃げる手を生成 生成される手はunique
Definition escape_.h:18
static void generateKingEscape(const NumEffectState &state, Action &action)
static void generateCaptureKing(const NumEffectState &state, Piece p, Square target, Action &action)
相手の駒を取ることによって利きを逃れる.
Definition escape_.h:42
static void generateMovesBy(const NumEffectState &state, Piece p, Action &action)
static void generateBlocking(const NumEffectState &state, Piece p, Square to, Square from, Action &action)
Square toにある玉以外の駒pにfromにある駒から王手がかかってい る時に,長い利きの途中に入る手を 生成する(合駒,駒移動). breakThreatmateから直接呼ばれる.
static void generateCapture(const NumEffectState &state, Piece p, Square target, Action &action)
Definition escape_.h:46
static void generateEscape(const NumEffectState &state, Piece p, Action &action, Int2Type< Type >)
static void generate(const NumEffectState &state, Piece piece, Action &action)
attacker からの利きを逃れる.
static void generateEscape(const NumEffectState &state, Piece p, Action &action)
Definition escape_.h:56
static void generateMoves(const NumEffectState &state, Piece piece, Piece attacker, Action &action)
attacker からの利きを逃れる.
static void generateBlockingKing(const NumEffectState &state, Piece p, Square from, Action &action)
玉pにfromにある駒から王手がかかってい る時に,長い利きの途中に入る手を 生成する(合駒,駒移動). breakThreatmateから直接呼ばれる.
static void generateMovesBy(const NumEffectState &state, Piece p, Move last_move, Action &action)
static void generateMovesBy(const NumEffectState &state, Piece p, Piece attacker, Action &action)
@ KING
Definition basic_type.h:93
@ BLACK
Definition basic_type.h:9
static void generate(const NumEffectState &state, MoveVector &out)
不成の受けも作成
Definition escape_.cc:9
static void generateCheap(const NumEffectState &state, MoveVector &out)
Definition escape_.cc:28
指手を MoveVector に保管
Definition move_action.h:16
static void generate(const NumEffectState &state, Piece piece, Action &a)
Definition escape_.h:145
static void generateCheapKingEscape(const NumEffectState &state, FixedCapacityVector< Move, Capacity > &out)
Definition escape_.h:136
static void generateCheap(const NumEffectState &state, Piece piece, Action &a)
Definition escape_.h:117
static void generateKingEscape(const NumEffectState &state, FixedCapacityVector< Move, Capacity > &out)
不成の受けは作成しないので必要な場合はユーザが作成
Definition escape_.h:130
static void generate(const NumEffectState &state, Piece piece, MoveVector &out)
Definition escape_.h:111
static void generate(const NumEffectState &state, Piece piece, Action &a)
Definition escape_.h:107
static void generateCheap(const NumEffectState &state, Piece piece, MoveVector &out)
Definition escape_.h:122
特定のpieceを動かす手を生成