My Project
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
7namespace 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();
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:
利きを持つ局面
Square mobilityOf(Direction d, int num) const
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
int number() const
Definition basic_type.h:828
bool isOnBoard() const
Definition basic_type.h:985
const Piece pieceAt(Square sq) const
int y() const
将棋としてのY座標を返す.
Definition basic_type.h:567
void countMobilityBoth(const NumEffectState &state, Square pos, Offset o, int &countAll, int &countSafe)
P : 駒pの持ち主 All : countAllを求めるかどうか? Safe : countAllを求めるかどうか? countAll : 利きに関係なく動けるマス countSafe : 相手の利き...
int countMobilitySafe(Player pl, const NumEffectState &state, Square pos, Offset o)
相手の利きがない動けるマスを求める
@ LANCE
Definition basic_type.h:96
Player
Definition basic_type.h:8
@ BLACK
Definition basic_type.h:9
盤上の香車の動けるマス
static int countAll(Player pl, const NumEffectState &state, Piece p)
static int countSafe(const NumEffectState &state, Piece p)
縦方向,相手の利きがない動けるマスを求める
static int countSafe(Player pl, const NumEffectState &state, Piece p)
static void countBoth(const NumEffectState &state, Piece p, int &countAll, int &countSafe)
縦方向, P : 駒pの持ち主 countAll : 利きに関係なく動けるマス countSafe : 相手の利きがない動けるマス 両方を求める
static void countBoth(Player pl, const NumEffectState &state, Piece p, int &countAll, int &countSafe)
static int countAll(const NumEffectState &state, Piece p)
static int countAll(const NumEffectState &state, Square pos, int num)
縦方向,利きに関係なく動けるマスの数