My Project
stateInfo.h
Go to the documentation of this file.
1 /* stateInfo.h
2  */
3 #ifndef OSL_MOVE_PROBABILITY_STATEINFO_H
4 #define OSL_MOVE_PROBABILITY_STATEINFO_H
5 
7 #include "osl/numEffectState.h"
8 #include "osl/bits/king8Info.h"
9 #include "osl/progress.h"
10 #include "osl/container.h"
11 #include "osl/container/square8.h"
13 #include <vector>
14 #include <algorithm>
15 
16 namespace osl
17 {
18  namespace move_probability
19  {
20  struct StateInfo
21  {
45  bool dirty;
46 
47  StateInfo() : state(0), history(0), progress16(0), dirty(true)
48  {
49  }
51  Move t=Move())
52  : state(&s), history(&h), progress16(p), dirty(true)
53  {
54  clearOldCache();
55  threatmate_move = t;
56  finishUpdate();
57  }
58  void reset0(const NumEffectState& s, Progress16 p)
59  {
60  dirty = true;
61  state = &s;
62  progress16 = p;
66  clearOldCache();
67  }
68  void reset1(const MoveStack& h)
69  {
70  history = &h;
71  }
72  void finishUpdate();
73  void reset(const NumEffectState& s, Progress16 p,
74  const MoveStack& h, Move threatmate_move=Move())
75  {
76  reset0(s, p);
77  reset1(h);
79  finishUpdate();
80  }
81  void setThreatmate(Move move) { threatmate_move = move; }
82 
83  bool pinByOpposingSliders(Piece p) const
84  {
87  }
89  {
90  return King8Info(state->Iking8Info(pl));
91  }
92  int progress8() const { return progress16.value()/2; }
93  static std::pair<Piece,Square> findCheckmateDefender(const NumEffectState& state, Player king);
94  static Move findShortThreatmate(const NumEffectState&, Move last_move);
95  private:
96  void clearOldCache();
97  void updateDelayed();
98  void makePinOfLongPieces();
100  void updatePinnedGenerals(Player owner);
101  };
102  bool operator==(const StateInfo& l, const StateInfo& r);
103  }
104 }
105 
106 #endif /* OSL_MOVE_PROBABILITY_STATEINFO_H */
107 // ;;; Local Variables:
108 // ;;; mode:c++
109 // ;;; c-basic-offset:2
110 // ;;; End:
圧縮していない moveの表現 .
Definition: basic_type.h:1052
利きを持つ局面
uint64_t Iking8Info(Player king) const
駒番号のビットセット.
Definition: pieceMask.h:21
敵玉の8近傍の状態を表す.
Definition: king8Info.h:29
Move のstack.
Definition: moveStack.h:15
bool operator==(const PinnedGeneral &l, const PinnedGeneral &r)
Definition: pinnedGeneral.h:20
ProgressN< 16 > Progress16
Definition: progress.h:42
Ptype
駒の種類を4ビットでコード化する
Definition: basic_type.h:84
Player
Definition: basic_type.h:8
FixedCapacityVector< PinnedGeneral, 64 > pinned_gs_t
Definition: stateInfo.h:37
void updatePinnedGenerals(Player owner)
Definition: stateInfo.cc:185
CArray< Move, 2 > bookmove
Definition: stateInfo.h:44
static std::pair< Piece, Square > findCheckmateDefender(const NumEffectState &state, Player king)
Definition: stateInfo.cc:160
CArray< Piece, 2 > threatened
Definition: stateInfo.h:26
void reset(const NumEffectState &s, Progress16 p, const MoveStack &h, Move threatmate_move=Move())
Definition: stateInfo.h:73
unsigned int possible_threatmate_ptype
Definition: stateInfo.h:43
const NumEffectState * state
Definition: stateInfo.h:22
CArray2d< bool, 40, 2 > attack_shadow
Definition: stateInfo.h:31
const MoveStack * history
Definition: stateInfo.h:23
static Move findShortThreatmate(const NumEffectState &, Move last_move)
Definition: stateInfo.cc:222
void reset0(const NumEffectState &s, Progress16 p)
Definition: stateInfo.h:58
void reset1(const MoveStack &h)
Definition: stateInfo.h:68
CArray< int, 16 > pattern_square_t
Definition: stateInfo.h:29
CArray< bool, 2 > move_candidate_exists
Definition: stateInfo.h:39
CArray< pinned_gs_t, 2 > exchange_pins
Definition: stateInfo.h:38
StateInfo(const NumEffectState &s, Progress16 p, const MoveStack &h, Move t=Move())
Definition: stateInfo.h:50
FixedCapacityVector< int, 8 > long_attack_t
Definition: stateInfo.h:27
bool pinByOpposingSliders(Piece p) const
Definition: stateInfo.h:83
CArray< std::pair< Piece, Square >, 2 > checkmate_defender
Definition: stateInfo.h:42
CArray< pattern_square_t, Square::SIZE > pattern_cache
Definition: stateInfo.h:30
King8Info king8Info(Player pl) const
Definition: stateInfo.h:88
void setThreatmate(Move move)
Definition: stateInfo.h:81
CArray< PieceMask, 2 > pin
Definition: stateInfo.h:34
CArray2d< long_attack_t, 40, 8 > long_attack_cache
Definition: stateInfo.h:28