My Project
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 
58 }
59 
60 // ;;; Local Variables:
61 // ;;; mode:c++
62 // ;;; c-basic-offset:2
63 // ;;; End:
osl::SimpleState::pieceAt
const Piece pieceAt(Square sq) const
Definition: simpleState.h:167
osl::Square
Definition: basic_type.h:532
osl::Square::isOnBoard
bool isOnBoard() const
盤面上を表すかどうかの判定. 1<=x() && x()<=9 && 1<=y() && y()<=9 Squareの内部表現に依存する.
Definition: basic_type.h:583
osl::Board_Table
const BoardTable Board_Table
Definition: tables.cc:95
osl::alt
constexpr Player alt(Player player)
Definition: basic_type.h:13
osl::PtypeTable::getEffect
const EffectContent getEffect(PtypeO ptypeo, Square from, Square to) const
fromにいるptypeoがtoに利きを持つか?
Definition: ptypeTable.h:112
osl::Offset32
Offset32Base< 8, 9 > Offset32
Definition: offset32.h:63
osl::Piece::ptypeO
PtypeO ptypeO() const
Definition: basic_type.h:824
osl::move_classifier::KingOpenMove::isMemberMain
static bool isMemberMain(const NumEffectState &state, Ptype ptype, Square from, Square to, Square exceptFor)
Definition: kingOpenMove.cc:7
osl::Offset
座標の差分
Definition: basic_type.h:430
osl::Ptype
Ptype
駒の種類を4ビットでコード化する
Definition: basic_type.h:84
osl::Ptype_Table
const PtypeTable Ptype_Table
Definition: tables.cc:97
osl::Piece
駒.
Definition: basic_type.h:788
osl::Offset::zero
bool zero() const
Definition: basic_type.h:502
osl::Square::isPieceStand
bool isPieceStand() const
Definition: basic_type.h:576
osl::Piece::isOnBoardByOwner
bool isOnBoardByOwner() const
piece がプレイヤーPの持ち物でかつボード上にある駒の場合は true.
Definition: basic_type.h:852
osl::move_classifier::KingOpenMove
Pの王をopen checkにする手でないことをチェック.
Definition: kingOpenMove.h:22
osl::Offset32Base
差が uniqになるような座標の差分.
Definition: offset32.h:17
osl::BoardTable::getShortOffsetNotKnight
const Offset getShortOffsetNotKnight(Offset32 offset32) const
Longの利きの可能性のあるoffsetの場合は, 反復に使う offsetを Knight以外のShortの利きのoffsetの場合はそれ自身を返す.
Definition: boardTable.h:119
osl::NumEffectState
利きを持つ局面
Definition: numEffectState.h:34
osl::SimpleState::isEmptyBetween
bool isEmptyBetween(Square from, Square to, Offset offset, bool pieceExistsAtTo=false) const
Definition: simpleState.h:267
kingOpenMove.h
osl::EffectContent::hasEffect
bool hasEffect() const
短い利きがあるか,間がemptyなら長い利きがある
Definition: effectContent.h:34
osl::Piece::isEmpty
bool isEmpty() const
Definition: basic_type.h:913
numEffectState.h
osl
Definition: additionalEffect.h:6