千日手の検出. More...
#include <repetitionCounter.h>
Classes | |
struct | Table |
Public Types | |
typedef std::list< int > | list_t |
Public Member Functions | |
RepetitionCounter () | |
RepetitionCounter (const RepetitionCounter &c) | |
RepetitionCounter (const NumEffectState &initial) | |
~RepetitionCounter () | |
void | push (const NumEffectState &state, Move move) |
state の状態で move を(これから)指すことを記録 More... | |
void | push (const NumEffectState &state) |
指した後の局面を記録 More... | |
void | push (const HashKey &key, const NumEffectState &state) |
指した後の局面を記録 More... | |
void | pop () |
void | clear () |
const Sennichite | isSennichite (const NumEffectState &state, Move move) const |
const Sennichite | isAlmostSennichite (const HashKey &key) const |
このまま同形を繰り返したらどの結果になるかを返す More... | |
const std::pair< Sennichite, int > | distanceToSennichite (const HashKey &key) const |
unsigned int | countRepetition (const HashKey &) const |
const list_t | getRepetitions (const HashKey &) const |
void | printMatches (const HashKey &key) const |
int | getLastMove (const HashKey &key) const |
key の手を最後に登録した指手番号. More... | |
int | getFirstMove (const HashKey &key) const |
key の手を最初に登録した指手番号. More... | |
int | checkCount (Player attack) const |
const HashKeyStack & | history () const |
bool | isConsistent () const |
Static Public Member Functions | |
static bool | maybeEqual (const RepetitionCounter &l, const RepetitionCounter &r) |
Private Member Functions | |
int | order () const |
void | push (const HashKey &new_key, bool is_check) |
const Sennichite | isAlmostSennichiteUnsafe (int first_move) const |
Private Attributes | |
std::unique_ptr< Table > | table |
CArray< std::vector< int >, 2 > | continuous_check |
HashKeyStack | hash_history |
千日手の検出.
連続王手の千日手(同一局面の最初と4回目の間の一方の指し手が王手のみだった場合)は、連続王手をかけていたほうが負け。 http://www.computer-shogi.org/wcsc14/youryou.html
Definition at line 20 of file repetitionCounter.h.
typedef std::list<int> osl::RepetitionCounter::list_t |
Definition at line 28 of file repetitionCounter.h.
osl::RepetitionCounter::RepetitionCounter | ( | ) |
Definition at line 35 of file repetitionCounter.cc.
References clear().
Referenced by clear(), and RepetitionCounter().
osl::RepetitionCounter::RepetitionCounter | ( | const RepetitionCounter & | c | ) |
Definition at line 41 of file repetitionCounter.cc.
References isConsistent(), RepetitionCounter(), and table.
|
explicit |
Definition at line 52 of file repetitionCounter.cc.
References clear(), push(), and ~RepetitionCounter().
osl::RepetitionCounter::~RepetitionCounter | ( | ) |
Definition at line 61 of file repetitionCounter.cc.
References push().
Referenced by RepetitionCounter().
|
inline |
Definition at line 91 of file repetitionCounter.h.
References osl::CArray< T, Capacity >::back().
Referenced by push(), and osl::checkmate::DualDfpn::writeRootHistory().
void osl::RepetitionCounter::clear | ( | ) |
Definition at line 20 of file repetitionCounter.cc.
References osl::hash::HashKeyStack::clear(), continuous_check, hash_history, initial_capacity, RepetitionCounter(), and table.
Referenced by RepetitionCounter().
unsigned int osl::RepetitionCounter::countRepetition | ( | const HashKey & | key | ) | const |
Definition at line 191 of file repetitionCounter.cc.
References getRepetitions(), and table.
Referenced by distanceToSennichite(), and isAlmostSennichite().
const std::pair< osl::Sennichite, int > osl::RepetitionCounter::distanceToSennichite | ( | const HashKey & | key | ) | const |
Definition at line 182 of file repetitionCounter.cc.
References countRepetition(), isAlmostSennichite(), osl::Sennichite::NORMAL(), and table.
Referenced by isAlmostSennichite(), and isSennichite().
int osl::RepetitionCounter::getFirstMove | ( | const HashKey & | key | ) | const |
key の手を最初に登録した指手番号.
Definition at line 153 of file repetitionCounter.cc.
References isSennichite(), and table.
Referenced by getLastMove(), and isAlmostSennichite().
int osl::RepetitionCounter::getLastMove | ( | const HashKey & | key | ) | const |
key の手を最後に登録した指手番号.
Definition at line 145 of file repetitionCounter.cc.
References getFirstMove(), and table.
Referenced by isAlmostSennichite(), and pop().
Definition at line 200 of file repetitionCounter.cc.
References printMatches(), and table.
Referenced by countRepetition(), and isAlmostSennichite().
|
inline |
Definition at line 95 of file repetitionCounter.h.
References hash_history, isConsistent(), and maybeEqual().
Referenced by isConsistent(), and osl::checkmate::DualDfpn::writeRootHistory().
|
inline |
このまま同形を繰り返したらどの結果になるかを返す
Definition at line 69 of file repetitionCounter.h.
References countRepetition(), distanceToSennichite(), getFirstMove(), getLastMove(), getRepetitions(), isAlmostSennichiteUnsafe(), osl::Sennichite::NORMAL(), and printMatches().
Referenced by distanceToSennichite(), and isSennichite().
|
inlineprivate |
Definition at line 55 of file repetitionCounter.h.
References osl::BLACK, osl::Sennichite::BLACK_LOSE(), osl::Sennichite::DRAW(), order(), osl::WHITE, and osl::Sennichite::WHITE_LOSE().
Referenced by isAlmostSennichite().
bool osl::RepetitionCounter::isConsistent | ( | ) | const |
Definition at line 222 of file repetitionCounter.cc.
References osl::alt(), continuous_check, osl::hash::HashKeyStack::empty(), hash_history, history(), order(), osl::hash::HashKeyStack::pop(), table, osl::hash::HashKeyStack::top(), and osl::hash::HashKey128::turn().
Referenced by history(), printMatches(), and RepetitionCounter().
const osl::Sennichite osl::RepetitionCounter::isSennichite | ( | const NumEffectState & | state, |
Move | move | ||
) | const |
Definition at line 167 of file repetitionCounter.cc.
References distanceToSennichite(), isAlmostSennichite(), osl::hash::HashKey::newHashWithMove(), osl::Sennichite::NORMAL(), and table.
Referenced by getFirstMove().
|
static |
Definition at line 256 of file repetitionCounter.cc.
References continuous_check, hash_history, and table.
Referenced by history().
|
inlineprivate |
Definition at line 26 of file repetitionCounter.h.
References osl::hash::HashKeyStack::size().
Referenced by isAlmostSennichiteUnsafe(), isConsistent(), pop(), and push().
void osl::RepetitionCounter::pop | ( | ) |
Definition at line 120 of file repetitionCounter.cc.
References osl::alt(), continuous_check, getLastMove(), hash_history, order(), osl::hash::HashKeyStack::pop(), osl::hash::HashKeyStack::size(), table, and osl::hash::HashKeyStack::top().
Referenced by push().
void osl::RepetitionCounter::printMatches | ( | const HashKey & | key | ) | const |
Definition at line 210 of file repetitionCounter.cc.
References isConsistent(), and table.
Referenced by getRepetitions(), and isAlmostSennichite().
|
private |
Definition at line 66 of file repetitionCounter.cc.
References osl::alt(), checkCount(), continuous_check, hash_history, order(), osl::hash::HashKeyStack::push(), table, and osl::hash::HashKey128::turn().
Referenced by push(), RepetitionCounter(), and ~RepetitionCounter().
void osl::RepetitionCounter::push | ( | const NumEffectState & | state, |
Move | move | ||
) |
state の状態で move を(これから)指すことを記録
Definition at line 105 of file repetitionCounter.cc.
References osl::NumEffectState::isCheck(), osl::Move::isPass(), osl::Move::isValidOrPass(), osl::Move::player(), pop(), push(), and osl::SimpleState::turn().
void osl::RepetitionCounter::push | ( | const NumEffectState & | state | ) |
void osl::RepetitionCounter::push | ( | const HashKey & | key, |
const NumEffectState & | state | ||
) |
指した後の局面を記録
Definition at line 92 of file repetitionCounter.cc.
References osl::NumEffectState::inCheck(), and push().
|
private |
Definition at line 24 of file repetitionCounter.h.
Referenced by clear(), isConsistent(), maybeEqual(), pop(), and push().
|
private |
Definition at line 25 of file repetitionCounter.h.
Referenced by clear(), history(), isConsistent(), maybeEqual(), pop(), and push().
|
private |
Definition at line 22 of file repetitionCounter.h.
Referenced by clear(), countRepetition(), distanceToSennichite(), getFirstMove(), getLastMove(), getRepetitions(), isConsistent(), isSennichite(), maybeEqual(), pop(), printMatches(), push(), and RepetitionCounter().