説明を見る。00001
00002
00003 #ifndef OSL_MOVE_PROBABILITY_STATEINFO_H
00004 #define OSL_MOVE_PROBABILITY_STATEINFO_H
00005
00006 #include "osl/move_probability/pinnedGeneral.h"
00007 #include "osl/numEffectState.h"
00008 #include "osl/bits/king8Info.h"
00009 #include "osl/progress.h"
00010 #include "osl/container.h"
00011 #include "osl/container/square8.h"
00012 #include "osl/container/moveStack.h"
00013 #include <vector>
00014 #include <algorithm>
00015
00016 namespace osl
00017 {
00018 namespace move_probability
00019 {
00020 struct StateInfo
00021 {
00022 const NumEffectState *state;
00023 const MoveStack *history;
00024 Progress16 progress16;
00025 PieceVector pin_by_opposing_sliders, king8_long_pieces;
00026 CArray<Piece,2> threatened;
00027 typedef FixedCapacityVector<int,8> long_attack_t;
00028 CArray2d<long_attack_t,40,8> long_attack_cache;
00029 typedef CArray<int,16> pattern_square_t;
00030 CArray<pattern_square_t,Square::SIZE> pattern_cache;
00031 CArray2d<bool,40,2> attack_shadow;
00032 PieceMask last_add_effect;
00033 Ptype last_move_ptype5;
00034 CArray<PieceMask,2> pin;
00035 Move threatmate_move;
00036 Square8 sendoffs;
00037 typedef FixedCapacityVector<PinnedGeneral,64> pinned_gs_t;
00038 CArray<pinned_gs_t,2> exchange_pins;
00039 CArray<bool,2> move_candidate_exists;
00040 mutable NumEffectState copy;
00041 BoardMask changed_effects;
00042 CArray<std::pair<Piece,Square>,2> checkmate_defender;
00043 unsigned int possible_threatmate_ptype;
00044 CArray<Move,2> bookmove;
00045 bool dirty;
00046
00047 StateInfo() : state(0), history(0), progress16(0), dirty(true)
00048 {
00049 }
00050 StateInfo(const NumEffectState& s, Progress16 p, const MoveStack& h,
00051 Move t=Move())
00052 : state(&s), history(&h), progress16(p), dirty(true)
00053 {
00054 clearOldCache();
00055 threatmate_move = t;
00056 finishUpdate();
00057 }
00058 void reset0(const NumEffectState& s, Progress16 p)
00059 {
00060 dirty = true;
00061 state = &s;
00062 progress16 = p;
00063 pin_by_opposing_sliders.clear();
00064 king8_long_pieces.clear();
00065 long_attack_cache.fill(long_attack_t());
00066 clearOldCache();
00067 }
00068 void reset1(const MoveStack& h)
00069 {
00070 history = &h;
00071 }
00072 void finishUpdate();
00073 void reset(const NumEffectState& s, Progress16 p,
00074 const MoveStack& h, Move threatmate_move=Move())
00075 {
00076 reset0(s, p);
00077 reset1(h);
00078 setThreatmate(threatmate_move);
00079 finishUpdate();
00080 }
00081 void setThreatmate(Move move) { threatmate_move = move; }
00082
00083 bool pinByOpposingSliders(Piece p) const
00084 {
00085 return std::find(pin_by_opposing_sliders.begin(), pin_by_opposing_sliders.end(),
00086 p) != pin_by_opposing_sliders.end();
00087 }
00088 King8Info king8Info(Player pl) const
00089 {
00090 return King8Info(state->Iking8Info(pl));
00091 }
00092 int progress8() const { return progress16.value()/2; }
00093 static std::pair<Piece,Square> findCheckmateDefender(const NumEffectState& state, Player king);
00094 static Move findShortThreatmate(const NumEffectState&, Move last_move);
00095 private:
00096 void clearOldCache();
00097 void updateDelayed();
00098 void makePinOfLongPieces();
00099 void makeLongAttacks();
00100 void updatePinnedGenerals(Player owner);
00101 };
00102 bool operator==(const StateInfo& l, const StateInfo& r);
00103 }
00104 }
00105
00106 #endif
00107
00108
00109
00110