stateInfo.h
Go to the documentation of this file.
/* stateInfo.h
*/
#ifndef OSL_MOVE_PROBABILITY_STATEINFO_H
#define OSL_MOVE_PROBABILITY_STATEINFO_H
#include "osl/move_probability/pinnedGeneral.h"
#include "osl/numEffectState.h"
#include "osl/bits/king8Info.h"
#include "osl/progress.h"
#include "osl/container.h"
#include "osl/container/square8.h"
#include "osl/container/moveStack.h"
#include <vector>
#include <algorithm>
namespace osl
{
namespace move_probability
{
struct StateInfo
{
const NumEffectState *state;
const MoveStack *history;
Progress16 progress16;
PieceVector pin_by_opposing_sliders, king8_long_pieces;
CArray<Piece,2> threatened;
typedef FixedCapacityVector<int,8> long_attack_t;
CArray2d<long_attack_t,40,8> long_attack_cache; // BlockLong
typedef CArray<int,16> pattern_square_t;
CArray<pattern_square_t,Square::SIZE> pattern_cache;
CArray2d<bool,40,2> attack_shadow;
PieceMask last_add_effect;
Ptype last_move_ptype5;
CArray<PieceMask,2> pin;
Move threatmate_move;
Square8 sendoffs;
typedef FixedCapacityVector<PinnedGeneral,64> pinned_gs_t;
CArray<pinned_gs_t,2> exchange_pins;
CArray<bool,2> move_candidate_exists; // king => bool
mutable NumEffectState copy;
BoardMask changed_effects;
CArray<std::pair<Piece,Square>,2> checkmate_defender;
unsigned int possible_threatmate_ptype;
CArray<Move,2> bookmove;
bool dirty;
StateInfo() : state(0), history(0), progress16(0), dirty(true)
{
}
StateInfo(const NumEffectState& s, Progress16 p, const MoveStack& h,
Move t=Move())
: state(&s), history(&h), progress16(p), dirty(true)
{
clearOldCache();
threatmate_move = t;
finishUpdate();
}
void reset0(const NumEffectState& s, Progress16 p)
{
dirty = true;
state = &s;
progress16 = p;
pin_by_opposing_sliders.clear();
king8_long_pieces.clear();
long_attack_cache.fill(long_attack_t());
clearOldCache();
}
void reset1(const MoveStack& h)
{
history = &h;
}
void finishUpdate();
void reset(const NumEffectState& s, Progress16 p,
const MoveStack& h, Move threatmate_move=Move())
{
reset0(s, p);
reset1(h);
setThreatmate(threatmate_move);
finishUpdate();
}
void setThreatmate(Move move) { threatmate_move = move; }
bool pinByOpposingSliders(Piece p) const
{
return std::find(pin_by_opposing_sliders.begin(), pin_by_opposing_sliders.end(),
p) != pin_by_opposing_sliders.end();
}
King8Info king8Info(Player pl) const
{
return King8Info(state->Iking8Info(pl));
}
int progress8() const { return progress16.value()/2; }
static std::pair<Piece,Square> findCheckmateDefender(const NumEffectState& state, Player king);
static Move findShortThreatmate(const NumEffectState&, Move last_move);
private:
void clearOldCache();
void updateDelayed();
void makePinOfLongPieces();
void makeLongAttacks();
void updatePinnedGenerals(Player owner);
};
bool operator==(const StateInfo& l, const StateInfo& r);
}
}
#endif /* OSL_MOVE_PROBABILITY_STATEINFO_H */
// ;;; Local Variables:
// ;;; mode:c++
// ;;; c-basic-offset:2
// ;;; End:
osl::CArray
Definition container.h:20
osl::FixedCapacityVector
Definition container.h:137
osl::Move
圧縮していない moveの表現 .
Definition basic_type.h:1052
osl::NumEffectState
利きを持つ局面
Definition numEffectState.h:34
osl::PieceMask
駒番号のビットセット.
Definition pieceMask.h:21
osl::PieceVector
Definition container.h:305
osl::Piece
駒.
Definition basic_type.h:788
osl::checkmate::King8Info
敵玉の8近傍の状態を表す.
Definition king8Info.h:29
osl::container::BoardMask
11 x 12
Definition boardMask.h:21
osl::container::MoveStack
Move のstack.
Definition moveStack.h:15
container.h
king8Info.h
moveStack.h
osl::move_probability
Definition move_probability/feature.h:15
osl::move_probability::operator==
bool operator==(const PinnedGeneral &l, const PinnedGeneral &r)
Definition pinnedGeneral.h:20
osl::progress::Progress16
ProgressN< 16 > Progress16
Definition progress.h:42
osl
Definition additionalEffect.h:6
osl::Ptype
Ptype
駒の種類を4ビットでコード化する
Definition basic_type.h:84
osl::CArray2d
CArray< CArray< T, Capacity2 >, Capacity1 > CArray2d
Definition container.h:95
osl::Player
Player
Definition basic_type.h:8
numEffectState.h
pinnedGeneral.h
progress.h
square8.h
osl::container::Square8
Definition square8.h:16
osl::move_probability::StateInfo
Definition stateInfo.h:21
osl::move_probability::StateInfo::clearOldCache
void clearOldCache()
Definition stateInfo.cc:14
osl::move_probability::StateInfo::pinned_gs_t
FixedCapacityVector< PinnedGeneral, 64 > pinned_gs_t
Definition stateInfo.h:37
osl::move_probability::StateInfo::updatePinnedGenerals
void updatePinnedGenerals(Player owner)
Definition stateInfo.cc:185
osl::move_probability::StateInfo::bookmove
CArray< Move, 2 > bookmove
Definition stateInfo.h:44
osl::move_probability::StateInfo::finishUpdate
void finishUpdate()
Definition stateInfo.cc:59
osl::move_probability::StateInfo::findCheckmateDefender
static std::pair< Piece, Square > findCheckmateDefender(const NumEffectState &state, Player king)
Definition stateInfo.cc:160
osl::move_probability::StateInfo::makeLongAttacks
void makeLongAttacks()
osl::move_probability::StateInfo::threatened
CArray< Piece, 2 > threatened
Definition stateInfo.h:26
osl::move_probability::StateInfo::sendoffs
Square8 sendoffs
Definition stateInfo.h:36
osl::move_probability::StateInfo::reset
void reset(const NumEffectState &s, Progress16 p, const MoveStack &h, Move threatmate_move=Move())
Definition stateInfo.h:73
osl::move_probability::StateInfo::updateDelayed
void updateDelayed()
osl::move_probability::StateInfo::possible_threatmate_ptype
unsigned int possible_threatmate_ptype
Definition stateInfo.h:43
osl::move_probability::StateInfo::state
const NumEffectState * state
Definition stateInfo.h:22
osl::move_probability::StateInfo::attack_shadow
CArray2d< bool, 40, 2 > attack_shadow
Definition stateInfo.h:31
osl::move_probability::StateInfo::last_move_ptype5
Ptype last_move_ptype5
Definition stateInfo.h:33
osl::move_probability::StateInfo::king8_long_pieces
PieceVector king8_long_pieces
Definition stateInfo.h:25
osl::move_probability::StateInfo::history
const MoveStack * history
Definition stateInfo.h:23
osl::move_probability::StateInfo::findShortThreatmate
static Move findShortThreatmate(const NumEffectState &, Move last_move)
Definition stateInfo.cc:222
osl::move_probability::StateInfo::reset0
void reset0(const NumEffectState &s, Progress16 p)
Definition stateInfo.h:58
osl::move_probability::StateInfo::threatmate_move
Move threatmate_move
Definition stateInfo.h:35
osl::move_probability::StateInfo::reset1
void reset1(const MoveStack &h)
Definition stateInfo.h:68
osl::move_probability::StateInfo::StateInfo
StateInfo()
Definition stateInfo.h:47
osl::move_probability::StateInfo::pattern_square_t
CArray< int, 16 > pattern_square_t
Definition stateInfo.h:29
osl::move_probability::StateInfo::progress8
int progress8() const
Definition stateInfo.h:92
osl::move_probability::StateInfo::move_candidate_exists
CArray< bool, 2 > move_candidate_exists
Definition stateInfo.h:39
osl::move_probability::StateInfo::exchange_pins
CArray< pinned_gs_t, 2 > exchange_pins
Definition stateInfo.h:38
osl::move_probability::StateInfo::dirty
bool dirty
Definition stateInfo.h:45
osl::move_probability::StateInfo::StateInfo
StateInfo(const NumEffectState &s, Progress16 p, const MoveStack &h, Move t=Move())
Definition stateInfo.h:50
osl::move_probability::StateInfo::long_attack_t
FixedCapacityVector< int, 8 > long_attack_t
Definition stateInfo.h:27
osl::move_probability::StateInfo::pinByOpposingSliders
bool pinByOpposingSliders(Piece p) const
Definition stateInfo.h:83
osl::move_probability::StateInfo::changed_effects
BoardMask changed_effects
Definition stateInfo.h:41
osl::move_probability::StateInfo::checkmate_defender
CArray< std::pair< Piece, Square >, 2 > checkmate_defender
Definition stateInfo.h:42
osl::move_probability::StateInfo::pattern_cache
CArray< pattern_square_t, Square::SIZE > pattern_cache
Definition stateInfo.h:30
osl::move_probability::StateInfo::makePinOfLongPieces
void makePinOfLongPieces()
Definition stateInfo.cc:103
osl::move_probability::StateInfo::king8Info
King8Info king8Info(Player pl) const
Definition stateInfo.h:88
osl::move_probability::StateInfo::last_add_effect
PieceMask last_add_effect
Definition stateInfo.h:32
osl::move_probability::StateInfo::setThreatmate
void setThreatmate(Move move)
Definition stateInfo.h:81
osl::move_probability::StateInfo::pin
CArray< PieceMask, 2 > pin
Definition stateInfo.h:34
osl::move_probability::StateInfo::progress16
Progress16 progress16
Definition stateInfo.h:24
osl::move_probability::StateInfo::copy
NumEffectState copy
Definition stateInfo.h:40
osl::move_probability::StateInfo::long_attack_cache
CArray2d< long_attack_t, 40, 8 > long_attack_cache
Definition stateInfo.h:28
osl::move_probability::StateInfo::pin_by_opposing_sliders
PieceVector pin_by_opposing_sliders
Definition stateInfo.h:25