escape_.h
Go to the documentation of this file.
#ifndef OSL_MOVE_GENERATOR_ESCAPE_H
#define OSL_MOVE_GENERATOR_ESCAPE_H
#include "osl/move_generator/pieceOnBoard.h"
#include "osl/move_generator/capture_.h"
#include "osl/move_generator/move_action.h"
#include "osl/basic_type.h"
namespace osl
{
namespace move_generator
{
template<class Action>
class Escape
{
public:
template<Player P,bool CheapOnly>
static void generateBlocking(const NumEffectState& state,Piece p,Square to,Square from,Action &action);
template<Player P,bool CheapOnly>
static void generateBlockingKing(const NumEffectState& state,Piece p,Square from,Action &action);
template<Player P>
static void generateCaptureKing(const NumEffectState& state,Piece p,Square target,Action& action) {
Capture<Action>::template escapeByCapture<P>(state,target,p,action);
}
template<Player P>
static void generateCapture(const NumEffectState& state,Piece p,Square target,Action& action) {
Capture<Action>::template escapeByCapture<P>(state,target,p,action);
}
template<Player P,Ptype Type>
static void generateEscape(const NumEffectState& state,Piece p,Action& action,Int2Type<Type>);
template<Player P,Ptype Type>
static void generateEscape(const NumEffectState& state,Piece p,Action& action){
if(Type==KING){
assert(p.owner()==P && p.ptype()==KING);
PieceOnBoard<Action>::template
generatePtype<P,Type>(state,p,action);
}
else
{
typedef move_action::NoEffectFilter<P,Action> CheckAction;
CheckAction checkAction(state,action,p.square());
PieceOnBoard<CheckAction>::template
generatePtype<P,Type>(state,p,
checkAction);
}
}
public:
template<Player P,bool cheapOnly>
static void generateKingEscape(const NumEffectState& state,Action& action);
template<Player P,Ptype Type,bool CheapOnly>
static void generateMovesBy(const NumEffectState& state,Piece p,Piece attacker,Action& action);
template<Player P,Ptype Type,bool CheapOnly>
static void generateMovesBy(const NumEffectState& state,Piece p,Move last_move,Action& action);
template<Player P,Ptype Type,bool CheapOnly>
static void generateMovesBy(const NumEffectState& state,Piece p,Action& action);
template<Player P,bool CheapOnly>
static void generateMoves(const NumEffectState& state,Piece piece,Piece attacker,Action& action);
template<Player P,bool shouldPromote,bool CheapOnly>
static void generate(const NumEffectState& state,Piece piece,Action& action);
};
template <Player P>
struct GenerateEscape
{
template <class Action>
static void generate(const NumEffectState& state, Piece piece, Action& a)
{
Escape<Action>::template generate<P,true,false>(state, piece, a);
}
static void generate(const NumEffectState& state, Piece piece, MoveVector& out)
{
move_action::Store store(out);
Escape<move_action::Store>::template generate<P,true,false>(state, piece, store);
}
template <class Action>
static void generateCheap(const NumEffectState& state, Piece piece, Action& a)
{
Escape<Action>::template generate<P,true,true>(state, piece, a);
}
static void generateCheap(const NumEffectState& state, Piece piece, MoveVector& out)
{
move_action::Store store(out);
Escape<move_action::Store>::template generate<P,true,false>(state, piece, store);
}
template <size_t Capacity>
static void generateKingEscape(const NumEffectState& state, FixedCapacityVector<Move,Capacity>& out)
{
move_action::Store store(out);
Escape<move_action::Store>::generateKingEscape<P,false>(state, store);
}
template <size_t Capacity>
static void generateCheapKingEscape(const NumEffectState& state, FixedCapacityVector<Move,Capacity>& out)
{
move_action::Store store(out);
Escape<move_action::Store>::generateKingEscape<P,true>(state, store);
}
};
struct GenerateEscapeOfTurn
{
template <class Action>
static void generate(const NumEffectState& state, Piece piece, Action& a)
{
if (state.turn() == BLACK)
{
Escape<Action>::template generate<BLACK,true,false>(state, piece, a);
}
else
{
Escape<Action>::template generate<WHITE,true,false>(state, piece, a);
}
}
};
} // namespace move_generator
struct GenerateEscapeKing
{
static void generate(const NumEffectState& state, MoveVector& out);
static void generateCheap(const NumEffectState& state, MoveVector& out);
};
using move_generator::GenerateEscape;
} // namespace osl
#endif // OSL_MOVE_GENERATOR_ESCAPE_H
// ;;; Local Variables:
// ;;; mode:c++
// ;;; c-basic-offset:2
// ;;; End:
basic_type.h
capture_.h
osl::FixedCapacityVector
Definition container.h:137
osl::MoveVector
Definition container.h:293
osl::Move
圧縮していない moveの表現 .
Definition basic_type.h:1052
osl::NumEffectState
利きを持つ局面
Definition numEffectState.h:34
osl::Piece
駒.
Definition basic_type.h:788
osl::Piece::ptype
Ptype ptype() const
Definition basic_type.h:821
osl::Piece::square
const Square square() const
Definition basic_type.h:832
osl::Piece::owner
Player owner() const
Definition basic_type.h:963
osl::SimpleState::turn
Player turn() const
Definition simpleState.h:220
osl::Square
Definition basic_type.h:532
osl::move_action::NoEffectFilter
利きのないところへ動くためのフィルタ
Definition move_action.h:73
osl::move_generator::Capture
駒を取る手を生成
Definition capture_.h:18
osl::move_generator::Escape
逃げる手を生成 生成される手はunique
Definition escape_.h:18
osl::move_generator::Escape::generateKingEscape
static void generateKingEscape(const NumEffectState &state, Action &action)
osl::move_generator::Escape::generateCaptureKing
static void generateCaptureKing(const NumEffectState &state, Piece p, Square target, Action &action)
相手の駒を取ることによって利きを逃れる.
Definition escape_.h:42
osl::move_generator::Escape::generateMovesBy
static void generateMovesBy(const NumEffectState &state, Piece p, Action &action)
osl::move_generator::Escape::generateBlocking
static void generateBlocking(const NumEffectState &state, Piece p, Square to, Square from, Action &action)
Square toにある玉以外の駒pにfromにある駒から王手がかかってい る時に，長い利きの途中に入る手を 生成する(合駒，駒移動)． breakThreatmateから直接呼ばれる．
osl::move_generator::Escape::generateCapture
static void generateCapture(const NumEffectState &state, Piece p, Square target, Action &action)
Definition escape_.h:46
osl::move_generator::Escape::generateEscape
static void generateEscape(const NumEffectState &state, Piece p, Action &action, Int2Type< Type >)
osl::move_generator::Escape::generate
static void generate(const NumEffectState &state, Piece piece, Action &action)
attacker からの利きを逃れる.
osl::move_generator::Escape::generateEscape
static void generateEscape(const NumEffectState &state, Piece p, Action &action)
Definition escape_.h:56
osl::move_generator::Escape::generateMoves
static void generateMoves(const NumEffectState &state, Piece piece, Piece attacker, Action &action)
attacker からの利きを逃れる.
osl::move_generator::Escape::generateBlockingKing
static void generateBlockingKing(const NumEffectState &state, Piece p, Square from, Action &action)
玉pにfromにある駒から王手がかかってい る時に，長い利きの途中に入る手を 生成する(合駒，駒移動)． breakThreatmateから直接呼ばれる．
osl::move_generator::Escape::generateMovesBy
static void generateMovesBy(const NumEffectState &state, Piece p, Move last_move, Action &action)
osl::move_generator::Escape::generateMovesBy
static void generateMovesBy(const NumEffectState &state, Piece p, Piece attacker, Action &action)
move_action.h
osl::move_generator
Definition addEffectWithEffect.cc:10
osl
Definition additionalEffect.h:6
osl::KING
@ KING
Definition basic_type.h:93
osl::BLACK
@ BLACK
Definition basic_type.h:9
pieceOnBoard.h
osl::GenerateEscapeKing
Definition escape_.h:160
osl::GenerateEscapeKing::generate
static void generate(const NumEffectState &state, MoveVector &out)
不成の受けも作成
Definition escape_.cc:9
osl::GenerateEscapeKing::generateCheap
static void generateCheap(const NumEffectState &state, MoveVector &out)
Definition escape_.cc:28
osl::misc::Int2Type
Definition basic_type.h:69
osl::move_action::Store
指手を MoveVector に保管
Definition move_action.h:16
osl::move_generator::GenerateEscapeOfTurn
Definition escape_.h:143
osl::move_generator::GenerateEscapeOfTurn::generate
static void generate(const NumEffectState &state, Piece piece, Action &a)
Definition escape_.h:145
osl::move_generator::GenerateEscape
Definition escape_.h:105
osl::move_generator::GenerateEscape::generateCheapKingEscape
static void generateCheapKingEscape(const NumEffectState &state, FixedCapacityVector< Move, Capacity > &out)
Definition escape_.h:136
osl::move_generator::GenerateEscape::generateCheap
static void generateCheap(const NumEffectState &state, Piece piece, Action &a)
Definition escape_.h:117
osl::move_generator::GenerateEscape::generateKingEscape
static void generateKingEscape(const NumEffectState &state, FixedCapacityVector< Move, Capacity > &out)
不成の受けは作成しないので必要な場合はユーザが作成
Definition escape_.h:130
osl::move_generator::GenerateEscape::generate
static void generate(const NumEffectState &state, Piece piece, MoveVector &out)
Definition escape_.h:111
osl::move_generator::GenerateEscape::generate
static void generate(const NumEffectState &state, Piece piece, Action &a)
Definition escape_.h:107
osl::move_generator::GenerateEscape::generateCheap
static void generateCheap(const NumEffectState &state, Piece piece, MoveVector &out)
Definition escape_.h:122
osl::move_generator::PieceOnBoard
特定のpieceを動かす手を生成
Definition pieceOnBoard.h:20