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 
7 #include "osl/numEffectState.h"
8 
9 namespace osl
10 {
11  namespace move_classifier
12  {
20  template <Player P>
21  struct KingOpenMove
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:
osl::Piece::number
int number() const
Definition: basic_type.h:828
osl::SimpleState::pieceAt
const Piece pieceAt(Square sq) const
Definition: simpleState.h:167
osl::Square
Definition: basic_type.h:532
osl::Board_Table
const BoardTable Board_Table
Definition: tables.cc:95
osl::move_classifier::KingOpenMove::isMemberMain
static bool isMemberMain(const NumEffectState &state, Ptype ptype, Square from, Square to, Square exceptFor)
Definition: kingOpenMove.cc:7
osl::move_classifier::ClassifierTraits
Definition: classifierTraits.h:11
osl::BoardTable::getShort8
Direction getShort8(Square from, Square to) const
Definition: boardTable.h:147
osl::Ptype
Ptype
駒の種類を4ビットでコード化する
Definition: basic_type.h:84
osl::PieceMask::test
bool test(int num) const
Definition: pieceMask.h:45
osl::move_classifier::KingOpenMove
Pの王をopen checkにする手でないことをチェック.
Definition: kingOpenMove.h:22
osl::move_classifier::KingOpenMove::isMember
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にはならな...
Definition: kingOpenMove.h:31
osl::NumEffectState::pinOrOpen
PieceMask pinOrOpen(Player king) const
Definition: numEffectState.h:74
osl::NumEffectState
利きを持つ局面
Definition: numEffectState.h:34
osl::BoardTable::getShort8Unsafe
Direction getShort8Unsafe(Square from, Square to) const
8方向にいない場合も適当なものを返す.
Definition: boardTable.h:134
osl::SimpleState::kingSquare
Square kingSquare() const
Definition: simpleState.h:94
osl::move_classifier::ClassifierTraits::drop_suitable
static const bool drop_suitable
Definition: classifierTraits.h:12
osl::Piece::isPieceNum
static bool isPieceNum(int num)
Definition: basic_type.h:926
osl::move_classifier::KingOpenMove::isMember
static bool isMember(const NumEffectState &state, Ptype ptype, Square from, Square to, Square exceptFor)
Definition: kingOpenMove.h:45
numEffectState.h
classifierTraits.h
osl::__attribute__
const PtypeO PTYPEO_EDGE __attribute__((unused))
osl
Definition: additionalEffect.h:6