kingOpenMove.cc
Go to the documentation of this file.
2 #include "osl/numEffectState.h"
3 
4 template <osl::Player P>
5 template <bool hasException>
7 isMemberMain(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 
48 namespace osl
49 {
50  // explicit template instantiation
53 
54  template bool move_classifier::KingOpenMove<BLACK>::isMemberMain<true>(const NumEffectState&, Ptype,Square,Square,Square);
55  template bool move_classifier::KingOpenMove<BLACK>::isMemberMain<false>(const NumEffectState&, Ptype,Square,Square,Square);
56  template bool move_classifier::KingOpenMove<WHITE>::isMemberMain<true>(const NumEffectState&, Ptype,Square,Square,Square);
57  template bool move_classifier::KingOpenMove<WHITE>::isMemberMain<false>(const NumEffectState&, Ptype,Square,Square,Square);
58 }
59 
60 // ;;; Local Variables:
61 // ;;; mode:c++
62 // ;;; c-basic-offset:2
63 // ;;; End:
bool isEmptyBetween(Square from, Square to, Offset offset, bool pieceExistsAtTo=false) const
Definition: simpleState.h:267
bool isOnBoardByOwner() const
piece がプレイヤーPの持ち物でかつボード上にある駒の場合は true.
Definition: basic_type.h:852
constexpr Player alt(Player player)
Definition: basic_type.h:13
bool zero() const
Definition: basic_type.h:502
座標の差分
Definition: basic_type.h:429
const Piece pieceAt(Square sq) const
Definition: simpleState.h:167
static bool isMemberMain(const NumEffectState &state, Ptype ptype, Square from, Square to, Square exceptFor)
Definition: kingOpenMove.cc:7
PtypeO ptypeO() const
Definition: basic_type.h:824
const Offset getShortOffsetNotKnight(Offset32 offset32) const
Longの利きの可能性のあるoffsetの場合は, 反復に使う offsetを Knight以外のShortの利きのoffsetの場合はそ...
Definition: boardTable.h:119
Offset32Base< 8, 9 > Offset32
Definition: offset32.h:63
Ptype
駒の種類を4ビットでコード化する
Definition: basic_type.h:83
const PtypeTable Ptype_Table
Definition: tables.cc:97
bool isOnBoard() const
盤面上を表すかどうかの判定. 1<=x() && x()<=9 && 1<=y() && y()<=9 Squareの内部表現に依存する. ...
Definition: basic_type.h:583
const EffectContent getEffect(PtypeO ptypeo, Square from, Square to) const
fromにいるptypeoがtoに利きを持つか?
Definition: ptypeTable.h:112
利きを持つ局面
bool isEmpty() const
Definition: basic_type.h:913
Pの王をopen checkにする手でないことをチェック.
Definition: kingOpenMove.h:21
bool isPieceStand() const
Definition: basic_type.h:576
const BoardTable Board_Table
Definition: tables.cc:95