My Project
kingOpenMove.cc
Go to the documentation of this file.
3
4template <osl::Player P>
5template <bool hasException>
7isMemberMain(const NumEffectState& state, Ptype, Square from, Square to,
8 Square exceptFor)
9{
10 assert(! from.isPieceStand());
11 Square king_position=state.template kingSquare<P>();
12 if (king_position.isPieceStand())
13 return false;
17 assert(king_position != from);
21 Offset offset=Board_Table.getShortOffsetNotKnight(Offset32(king_position,from));
26 if(offset.zero() ||
27 offset==Board_Table.getShortOffsetNotKnight(Offset32(king_position,to)))
28 return false;
29 if(!state.isEmptyBetween(from,king_position,offset,true)) return false;
30 Square pos=from;
31 Piece p;
32 for(pos-=offset;;pos-=offset){
33 // TODO: exceptFor を毎回チェックする必要があるのはoffset方向の時だけ
34 if (! ((hasException && (pos == exceptFor))
35 || (p=state.pieceAt(pos), p.isEmpty())))
36 break;
37 assert(pos.isOnBoard());
38 }
43 if (! p.isOnBoardByOwner<alt(P)>())
44 return false;
45 return Ptype_Table.getEffect(p.ptypeO(),pos,king_position).hasEffect();
46}
47
48namespace osl
49{
50 // explicit template instantiation
53
58}
59
60// ;;; Local Variables:
61// ;;; mode:c++
62// ;;; c-basic-offset:2
63// ;;; End:
const Offset getShortOffsetNotKnight(Offset32 offset32) const
Longの利きの可能性のあるoffsetの場合は, 反復に使う offsetを Knight以外のShortの利きのoffsetの場合はそれ自身を返す.
Definition boardTable.h:119
bool hasEffect() const
短い利きがあるか,間がemptyなら長い利きがある
利きを持つ局面
差が uniqになるような座標の差分.
Definition offset32.h:17
座標の差分
Definition basic_type.h:430
bool zero() const
Definition basic_type.h:502
PtypeO ptypeO() const
Definition basic_type.h:824
bool isEmpty() const
Definition basic_type.h:913
bool isOnBoardByOwner() const
piece がプレイヤーPの持ち物でかつボード上にある駒の場合は true.
Definition basic_type.h:852
const EffectContent getEffect(PtypeO ptypeo, Square from, Square to) const
fromにいるptypeoがtoに利きを持つか?
Definition ptypeTable.h:112
bool isEmptyBetween(Square from, Square to, Offset offset, bool pieceExistsAtTo=false) const
const Piece pieceAt(Square sq) const
bool isPieceStand() const
Definition basic_type.h:576
bool isOnBoard() const
盤面上を表すかどうかの判定. 1<=x() && x()<=9 && 1<=y() && y()<=9 Squareの内部表現に依存する.
Definition basic_type.h:583
Ptype
駒の種類を4ビットでコード化する
Definition basic_type.h:84
const PtypeTable Ptype_Table
Definition tables.cc:97
const BoardTable Board_Table
Definition tables.cc:95
constexpr Player alt(Player player)
Definition basic_type.h:13
Pの王をopen checkにする手でないことをチェック.
static bool isMemberMain(const NumEffectState &state, Ptype ptype, Square from, Square to, Square exceptFor)