My Project
kingOpenMove.h
Go to the documentation of this file.
1/* kingOpenMove.h
2 */
3#ifndef OSL_MOVE_CLASSIFIER_KING_OPEN_MOVE_H
4#define OSL_MOVE_CLASSIFIER_KING_OPEN_MOVE_H
5
8
9namespace osl
10{
11 namespace move_classifier
12 {
20 template <Player P>
22 {
31 static bool isMember(const NumEffectState& state,
32 Ptype /*ptype*/,Square from,Square to)
33 {
34 int num=state.pieceAt(from).number();
35 assert(Piece::isPieceNum(num));
36 if(!state.pinOrOpen(P).test(num)) return false;
37 // from to kingが一直線に並べば false
38 Square king=state.kingSquare<P>();
39 return Board_Table.getShort8Unsafe<P>(king,to)
40 != Board_Table.getShort8<P>(king,from);
41 }
45 static bool isMember(const NumEffectState& state,
46 Ptype ptype,Square from,Square to,
47 Square exceptFor)
48 {
49 return isMemberMain<true>(state, ptype, from, to, exceptFor);
50 }
51 private:
52 template <bool hasException>
53 static bool
54#ifdef __GNUC__
55 __attribute__ ((pure))
56#endif
57 isMemberMain(const NumEffectState& state,
58 Ptype ptype,Square from,Square to,
59 Square exceptFor);
60 };
61
62 template <Player P> struct ClassifierTraits<KingOpenMove<P> >
63 {
64 static const bool drop_suitable = false;
65 static const bool result_if_drop = false;
66 };
67
68 } // namespace move_classifier
69} // namespace osl
70#endif /* OSL_MOVE_CLASSIFIER_NOT_KING_OPEN_MOVE_H */
71// ;;; Local Variables:
72// ;;; mode:c++
73// ;;; c-basic-offset:2
74// ;;; End:
Direction getShort8Unsafe(Square from, Square to) const
8方向にいない場合も適当なものを返す.
Definition boardTable.h:134
Direction getShort8(Square from, Square to) const
Definition boardTable.h:147
利きを持つ局面
PieceMask pinOrOpen(Player king) const
bool test(int num) const
Definition pieceMask.h:45
static bool isPieceNum(int num)
Definition basic_type.h:926
int number() const
Definition basic_type.h:828
Square kingSquare() const
Definition simpleState.h:94
const Piece pieceAt(Square sq) const
Ptype
駒の種類を4ビットでコード化する
Definition basic_type.h:84
const BoardTable Board_Table
Definition tables.cc:95
const PtypeO PTYPEO_EDGE __attribute__((unused))
Pの王をopen checkにする手でないことをチェック.
static bool isMemberMain(const NumEffectState &state, Ptype ptype, Square from, Square to, Square exceptFor)
static bool isMember(const NumEffectState &state, Ptype, Square from, Square to)
king が59 rookが51->61の時,差は OFFSET -8 -> U OFFSET +8 -> D とはなるので,一直線のような気がする.ただし,そもとも, 59 - 51はpinにはならな...
static bool isMember(const NumEffectState &state, Ptype ptype, Square from, Square to, Square exceptFor)