lanceMobility.h
Go to the documentation of this file.
1 /* lanceMobility.h
2  */
3 #ifndef MOBILITY_LANCE_MOBILITY_H
4 #define MOBILITY_LANCE_MOBILITY_H
6 
7 namespace osl
8 {
9  namespace mobility
10  {
15  {
16  public:
24  template<Player P>
25  static void countBoth(const NumEffectState& state,Piece p,int& countAll,int& countSafe){
26  assert(p.ptype()==LANCE);
27  assert(p.isOnBoard());
28  assert(p.owner()==P);
29  const Square pos=p.square();
30  countMobilityBoth(P,state,pos,DirectionPlayerTraits<U,P>::offset(),countAll,countSafe);
31  }
32  static void countBoth(Player pl,const NumEffectState& state,Piece p,int& countAll,int &countSafe){
33  if(pl==BLACK)
34  countBoth<BLACK>(state,p,countAll,countSafe);
35  else
36  countBoth<WHITE>(state,p,countAll,countSafe);
37  }
41  template<Player P>
42  static int countAll(const NumEffectState& state,Square pos,int num){
44  int count=(P==BLACK ? pos.y()-pos1.y() : pos1.y()- pos.y())-1+
45  (state.pieceAt(pos1).template canMoveOn<P>() ? 1 : 0);
46  return count;
47  }
48  template<Player P>
49  static int countAll(const NumEffectState& state,Piece p){
50  assert(p.ptype()==LANCE);
51  assert(p.isOnBoard());
52  assert(p.owner()==P);
53  return countAll<P>(state,p.square(),p.number());
54  }
55  static int countAll(Player pl,const NumEffectState& state,Piece p){
56  if(pl==BLACK)
57  return countAll<BLACK>(state,p);
58  else
59  return countAll<WHITE>(state,p);
60  }
64  template<Player P>
65  static int countSafe(const NumEffectState& state,Piece p){
66  assert(p.ptype()==LANCE);
67  assert(p.isOnBoard());
68  assert(p.owner()==P);
69  const Square pos=p.square();
70  return
72  }
73  static int countSafe(Player pl,const NumEffectState& state,Piece p){
74  if(pl==BLACK)
75  return countSafe<BLACK>(state,p);
76  else
77  return countSafe<WHITE>(state,p);
78  }
79  };
80  }
81 }
82 #endif /* MOBILITY_LANCE_MOBILITY_H */
83 // ;;; Local Variables:
84 // ;;; mode:c++
85 // ;;; c-basic-offset:2
86 // ;;; End:
static int countSafe(const NumEffectState &state, Piece p)
縦方向,相手の利きがない動けるマスを求める
Definition: lanceMobility.h:65
bool isOnBoard() const
Definition: basic_type.h:985
int number() const
Definition: basic_type.h:828
static int countAll(Player pl, const NumEffectState &state, Piece p)
Definition: lanceMobility.h:55
Ptype ptype() const
Definition: basic_type.h:821
const Piece pieceAt(Square sq) const
Definition: simpleState.h:167
int y() const
将棋としてのY座標を返す.
Definition: basic_type.h:567
static int countAll(const NumEffectState &state, Piece p)
Definition: lanceMobility.h:49
static void countBoth(const NumEffectState &state, Piece p, int &countAll, int &countSafe)
縦方向, P : 駒pの持ち主 countAll : 利きに関係なく動けるマス countSafe : 相手の利きがない動けるマス ...
Definition: lanceMobility.h:25
Square mobilityOf(Direction d, int num) const
int countMobilitySafe(Player pl, const NumEffectState &state, Square pos, Offset o)
相手の利きがない動けるマスを求める
Definition: countMobility.h:56
static int countSafe(Player pl, const NumEffectState &state, Piece p)
Definition: lanceMobility.h:73
利きを持つ局面
static int countAll(const NumEffectState &state, Square pos, int num)
縦方向,利きに関係なく動けるマスの数
Definition: lanceMobility.h:42
const Square square() const
Definition: basic_type.h:832
盤上の香車の動けるマス
Definition: lanceMobility.h:14
void countMobilityBoth(const NumEffectState &state, Square pos, Offset o, int &countAll, int &countSafe)
P : 駒pの持ち主 All : countAllを求めるかどうか? Safe : countAllを求めるかどうか? countAll : 利きに関...
Definition: countMobility.h:20
Player
Definition: basic_type.h:8
static void countBoth(Player pl, const NumEffectState &state, Piece p, int &countAll, int &countSafe)
Definition: lanceMobility.h:32
Player owner() const
Definition: basic_type.h:963