kingOpenMove.cc
Go to the documentation of this file.
#include "osl/move_classifier/kingOpenMove.h"
#include "osl/numEffectState.h"
template <osl::Player P>
template <bool hasException>
bool osl::move_classifier::KingOpenMove<P>::
isMemberMain(const NumEffectState& state, Ptype, Square from, Square to,
Square exceptFor)
{
assert(! from.isPieceStand());
Square king_position=state.template kingSquare<P>();
if (king_position.isPieceStand())
return false;
assert(king_position != from);
Offset offset=Board_Table.getShortOffsetNotKnight(Offset32(king_position,from));
if(offset.zero() ||
offset==Board_Table.getShortOffsetNotKnight(Offset32(king_position,to)))
return false;
if(!state.isEmptyBetween(from,king_position,offset,true)) return false;
Square pos=from;
Piece p;
for(pos-=offset;;pos-=offset){
// TODO: exceptFor を毎回チェックする必要があるのはoffset方向の時だけ
if (! ((hasException && (pos == exceptFor))
|| (p=state.pieceAt(pos), p.isEmpty())))
break;
assert(pos.isOnBoard());
}
if (! p.isOnBoardByOwner<alt(P)>())
return false;
return Ptype_Table.getEffect(p.ptypeO(),pos,king_position).hasEffect();
}
namespace osl
{
// explicit template instantiation
template struct move_classifier::KingOpenMove<BLACK>;
template struct move_classifier::KingOpenMove<WHITE>;
template bool move_classifier::KingOpenMove<BLACK>::isMemberMain<true>(const NumEffectState&, Ptype,Square,Square,Square);
template bool move_classifier::KingOpenMove<BLACK>::isMemberMain<false>(const NumEffectState&, Ptype,Square,Square,Square);
template bool move_classifier::KingOpenMove<WHITE>::isMemberMain<true>(const NumEffectState&, Ptype,Square,Square,Square);
template bool move_classifier::KingOpenMove<WHITE>::isMemberMain<false>(const NumEffectState&, Ptype,Square,Square,Square);
}
// ;;; Local Variables:
// ;;; mode:c++
// ;;; c-basic-offset:2
// ;;; End:
osl::NumEffectState
利きを持つ局面
Definition numEffectState.h:34
osl::Offset
座標の差分
Definition basic_type.h:430
osl::Offset::zero
bool zero() const
Definition basic_type.h:502
osl::Piece
駒.
Definition basic_type.h:788
osl::Piece::ptypeO
PtypeO ptypeO() const
Definition basic_type.h:824
osl::Piece::isEmpty
bool isEmpty() const
Definition basic_type.h:913
osl::Piece::isOnBoardByOwner
bool isOnBoardByOwner() const
piece がプレイヤーPの持ち物でかつボード上にある駒の場合は true.
Definition basic_type.h:852
osl::SimpleState::isEmptyBetween
bool isEmptyBetween(Square from, Square to, Offset offset, bool pieceExistsAtTo=false) const
Definition simpleState.h:267
osl::SimpleState::pieceAt
const Piece pieceAt(Square sq) const
Definition simpleState.h:167
osl::Square
Definition basic_type.h:532
osl::Square::isPieceStand
bool isPieceStand() const
Definition basic_type.h:576
osl::Square::isOnBoard
bool isOnBoard() const
盤面上を表すかどうかの判定． 1<=x() && x()<=9 && 1<=y() && y()<=9 Squareの内部表現に依存する．
Definition basic_type.h:583
kingOpenMove.h
osl
Definition additionalEffect.h:6
osl::Ptype
Ptype
駒の種類を4ビットでコード化する
Definition basic_type.h:84
osl::Ptype_Table
const PtypeTable Ptype_Table
Definition tables.cc:97
osl::Board_Table
const BoardTable Board_Table
Definition tables.cc:95
osl::Offset32
Offset32Base< 8, 9 > Offset32
Definition offset32.h:63
osl::alt
constexpr Player alt(Player player)
Definition basic_type.h:13
numEffectState.h
osl::move_classifier::KingOpenMove
Pの王をopen checkにする手でないことをチェック.
Definition kingOpenMove.h:22
osl::move_classifier::KingOpenMove::isMemberMain
static bool isMemberMain(const NumEffectState &state, Ptype ptype, Square from, Square to, Square exceptFor)
Definition kingOpenMove.cc:7