lanceMobility.h
Go to the documentation of this file.
/* lanceMobility.h
*/
#ifndef MOBILITY_LANCE_MOBILITY_H
#define MOBILITY_LANCE_MOBILITY_H
#include "osl/mobility/countMobility.h"
namespace osl
{
namespace mobility
{
struct LanceMobility
{
public:
template<Player P>
static void countBoth(const NumEffectState& state,Piece p,int& countAll,int& countSafe){
assert(p.ptype()==LANCE);
assert(p.isOnBoard());
assert(p.owner()==P);
const Square pos=p.square();
countMobilityBoth(P,state,pos,DirectionPlayerTraits<U,P>::offset(),countAll,countSafe);
}
static void countBoth(Player pl,const NumEffectState& state,Piece p,int& countAll,int &countSafe){
if(pl==BLACK)
countBoth<BLACK>(state,p,countAll,countSafe);
else
countBoth<WHITE>(state,p,countAll,countSafe);
}
template<Player P>
static int countAll(const NumEffectState& state,Square pos,int num){
const Square pos1=state.mobilityOf(DirectionPlayerTraits<U,P>::directionByBlack,num);
int count=(P==BLACK ? pos.y()-pos1.y() : pos1.y()- pos.y())-1+
(state.pieceAt(pos1).template canMoveOn<P>() ? 1 : 0);
return count;
}
template<Player P>
static int countAll(const NumEffectState& state,Piece p){
assert(p.ptype()==LANCE);
assert(p.isOnBoard());
assert(p.owner()==P);
return countAll<P>(state,p.square(),p.number());
}
static int countAll(Player pl,const NumEffectState& state,Piece p){
if(pl==BLACK)
return countAll<BLACK>(state,p);
else
return countAll<WHITE>(state,p);
}
template<Player P>
static int countSafe(const NumEffectState& state,Piece p){
assert(p.ptype()==LANCE);
assert(p.isOnBoard());
assert(p.owner()==P);
const Square pos=p.square();
return
countMobilitySafe(P,state,pos,DirectionPlayerTraits<U,P>::offset());
}
static int countSafe(Player pl,const NumEffectState& state,Piece p){
if(pl==BLACK)
return countSafe<BLACK>(state,p);
else
return countSafe<WHITE>(state,p);
}
};
}
}
#endif /* MOBILITY_LANCE_MOBILITY_H */
// ;;; Local Variables:
// ;;; mode:c++
// ;;; c-basic-offset:2
// ;;; End:
osl::NumEffectState
利きを持つ局面
Definition numEffectState.h:34
osl::NumEffectState::mobilityOf
Square mobilityOf(Direction d, int num) const
Definition numEffectState.h:175
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::Piece::number
int number() const
Definition basic_type.h:828
osl::Piece::isOnBoard
bool isOnBoard() const
Definition basic_type.h:985
osl::SimpleState::pieceAt
const Piece pieceAt(Square sq) const
Definition simpleState.h:167
osl::Square
Definition basic_type.h:532
osl::Square::y
int y() const
将棋としてのY座標を返す.
Definition basic_type.h:567
countMobility.h
osl::mobility
Definition bishopMobility.h:11
osl::mobility::countMobilityBoth
void countMobilityBoth(const NumEffectState &state, Square pos, Offset o, int &countAll, int &countSafe)
P : 駒pの持ち主 All : countAllを求めるかどうか?
Definition countMobility.h:20
osl::mobility::countMobilitySafe
int countMobilitySafe(Player pl, const NumEffectState &state, Square pos, Offset o)
相手の利きがない動けるマスを求める
Definition countMobility.h:56
osl
Definition additionalEffect.h:6
osl::LANCE
@ LANCE
Definition basic_type.h:96
osl::Player
Player
Definition basic_type.h:8
osl::BLACK
@ BLACK
Definition basic_type.h:9
osl::DirectionPlayerTraits
Definition directionTraits.h:242
osl::mobility::LanceMobility
盤上の香車の動けるマス
Definition lanceMobility.h:15
osl::mobility::LanceMobility::countAll
static int countAll(Player pl, const NumEffectState &state, Piece p)
Definition lanceMobility.h:55
osl::mobility::LanceMobility::countSafe
static int countSafe(const NumEffectState &state, Piece p)
縦方向，相手の利きがない動けるマスを求める
Definition lanceMobility.h:65
osl::mobility::LanceMobility::countSafe
static int countSafe(Player pl, const NumEffectState &state, Piece p)
Definition lanceMobility.h:73
osl::mobility::LanceMobility::countBoth
static void countBoth(const NumEffectState &state, Piece p, int &countAll, int &countSafe)
縦方向， P : 駒pの持ち主 countAll : 利きに関係なく動けるマス countSafe : 相手の利きがない動けるマス 両方を求める
Definition lanceMobility.h:25
osl::mobility::LanceMobility::countBoth
static void countBoth(Player pl, const NumEffectState &state, Piece p, int &countAll, int &countSafe)
Definition lanceMobility.h:32
osl::mobility::LanceMobility::countAll
static int countAll(const NumEffectState &state, Piece p)
Definition lanceMobility.h:49
osl::mobility::LanceMobility::countAll
static int countAll(const NumEffectState &state, Square pos, int num)
縦方向，利きに関係なく動けるマスの数
Definition lanceMobility.h:42