osl::RepetitionCounter Class Reference

千日手の検出. 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 を(これから)指すことを記録
void | push (const NumEffectState &state)
| 指した後の局面を記録
void | push (const HashKey &key, const NumEffectState &state)
| 指した後の局面を記録
void | pop ()
void | clear ()
const Sennichite | isSennichite (const NumEffectState &state, Move move) const
const Sennichite | isAlmostSennichite (const HashKey &key) const
| このまま同形を繰り返したらどの結果になるかを返す
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 の手を最後に登録した指手番号.
int | getFirstMove (const HashKey &key) const
| key の手を最初に登録した指手番号.
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

## Detailed Description

千日手の検出.

連続王手の千日手(同一局面の最初と4回目の間の一方の指し手が王手のみだった場合)は、連続王手をかけていたほうが負け。 http://www.computer-shogi.org/wcsc14/youryou.html

Definition at line 20 of file repetitionCounter.h.

## Member Typedef Documentation

## list_t

typedef std::list<int> osl::RepetitionCounter::list_t

Definition at line 28 of file repetitionCounter.h.

## Constructor & Destructor Documentation

## RepetitionCounter() [1/3]

osl::RepetitionCounter::RepetitionCounter | ( |  | ) |

Definition at line 34 of file repetitionCounter.cc.

References clear(), hash_history, initial_capacity, and table.

Referenced by maybeEqual(), and RepetitionCounter().

## RepetitionCounter() [2/3]

osl::RepetitionCounter::RepetitionCounter | ( | const RepetitionCounter & | c | ) |

Definition at line 40 of file repetitionCounter.cc.

References continuous_check, hash_history, isConsistent(), RepetitionCounter(), and table.

## RepetitionCounter() [3/3]

osl::RepetitionCounter::RepetitionCounter | ( | const NumEffectState & | initial | ) |

explicit

Definition at line 51 of file repetitionCounter.cc.

References clear(), hash_history, initial_capacity, push(), and table.

## ~RepetitionCounter()

osl::RepetitionCounter::~RepetitionCounter | ( |  | ) |

Definition at line 60 of file repetitionCounter.cc.

## Member Function Documentation

## checkCount()

int osl::RepetitionCounter::checkCount | ( | Player | attack | ) | const

inline

Definition at line 91 of file repetitionCounter.h.

References continuous_check.

Referenced by push(), and osl::checkmate::DualDfpn::writeRootHistory().

## clear()

void osl::RepetitionCounter::clear | ( |  | ) |

Definition at line 19 of file repetitionCounter.cc.

References continuous_check, hash_history, initial_capacity, and table.

Referenced by RepetitionCounter(), and RepetitionCounter().

## countRepetition()

unsigned int osl::RepetitionCounter::countRepetition | ( | const HashKey & | key | ) | const

Definition at line 190 of file repetitionCounter.cc.

References table.

## distanceToSennichite()

const std::pair< osl::Sennichite, int > osl::RepetitionCounter::distanceToSennichite | ( | const HashKey & | key | ) | const

Returns
  pair<isAlmostSennichite, count>

Definition at line 181 of file repetitionCounter.cc.

References isAlmostSennichite(), osl::Sennichite::NORMAL(), and table.

## getFirstMove()

int osl::RepetitionCounter::getFirstMove | ( | const HashKey & | key | ) | const

key の手を最初に登録した指手番号.

Returns
  初めての局面では-1

Definition at line 152 of file repetitionCounter.cc.

References table.

Referenced by isAlmostSennichite().

## getLastMove()

int osl::RepetitionCounter::getLastMove | ( | const HashKey & | key | ) | const

key の手を最後に登録した指手番号.

Returns
  初めての局面では-1

Definition at line 144 of file repetitionCounter.cc.

References table.

## getRepetitions()

const list_t osl::RepetitionCounter::getRepetitions | ( | const HashKey & | key | ) | const

Definition at line 199 of file repetitionCounter.cc.

References table.

## history()

const HashKeyStack & osl::RepetitionCounter::history | ( |  | ) | const

inline

Definition at line 95 of file repetitionCounter.h.

References hash_history.

Referenced by isConsistent(), and osl::checkmate::DualDfpn::writeRootHistory().

## isAlmostSennichite()

const Sennichite osl::RepetitionCounter::isAlmostSennichite | ( | const HashKey & | key | ) | const

inline

このまま同形を繰り返したらどの結果になるかを返す

Definition at line 69 of file repetitionCounter.h.

References getFirstMove(), isAlmostSennichiteUnsafe(), and osl::Sennichite::NORMAL().

Referenced by distanceToSennichite(), and isSennichite().

## isAlmostSennichiteUnsafe()

const Sennichite osl::RepetitionCounter::isAlmostSennichiteUnsafe | ( | int | first_move | ) | const

inline private

Definition at line 55 of file repetitionCounter.h.

References osl::BLACK, osl::Sennichite::BLACK_LOSE(), continuous_check, osl::Sennichite::DRAW(), order(), osl::WHITE, and osl::Sennichite::WHITE_LOSE().

Referenced by isAlmostSennichite().

## isConsistent()

bool osl::RepetitionCounter::isConsistent | ( |  | ) | const

Definition at line 221 of file repetitionCounter.cc.

References osl::alt(), continuous_check, hash_history, history(), order(), table, and osl::hash::HashKey128::turn().

Referenced by RepetitionCounter().

## isSennichite()

const osl::Sennichite osl::RepetitionCounter::isSennichite | ( | const NumEffectState & | state,
|  | Move | move ) const

Definition at line 166 of file repetitionCounter.cc.

References isAlmostSennichite(), osl::hash::HashKey::newHashWithMove(), osl::Sennichite::NORMAL(), and table.

## maybeEqual()

bool osl::RepetitionCounter::maybeEqual | ( | const RepetitionCounter & | l,
|  | const RepetitionCounter & | r )

static

Definition at line 256 of file repetitionCounter.cc.

References continuous_check, hash_history, RepetitionCounter(), and table.

## order()

int osl::RepetitionCounter::order | ( |  | ) | const

inline private

Definition at line 26 of file repetitionCounter.h.

References hash_history.

Referenced by isAlmostSennichiteUnsafe(), isConsistent(), pop(), and push().

## pop()

void osl::RepetitionCounter::pop | ( |  | ) |

Definition at line 119 of file repetitionCounter.cc.

References osl::alt(), continuous_check, hash_history, order(), table, and osl::hash::HashKey128::turn().

## printMatches()

void osl::RepetitionCounter::printMatches | ( | const HashKey & | key | ) | const

Definition at line 209 of file repetitionCounter.cc.

References table.

## push() [1/4]

void osl::RepetitionCounter::push | ( | const HashKey & | key,
|  | const NumEffectState & | state )

指した後の局面を記録

Definition at line 91 of file repetitionCounter.cc.

References osl::NumEffectState::inCheck(), and push().

## push() [2/4]

void osl::RepetitionCounter::push | ( | const HashKey & | new_key,
|  | bool | is_check )

private

Definition at line 65 of file repetitionCounter.cc.

References osl::alt(), checkCount(), continuous_check, hash_history, order(), table, and osl::hash::HashKey128::turn().

Referenced by push(), push(), push(), and RepetitionCounter().

## push() [3/4]

void osl::RepetitionCounter::push | ( | const NumEffectState & | state | ) |

指した後の局面を記録

Definition at line 98 of file repetitionCounter.cc.

References push().

## push() [4/4]

void osl::RepetitionCounter::push | ( | const NumEffectState & | state,
|  | Move | move )

state の状態で move を(これから)指すことを記録

Definition at line 104 of file repetitionCounter.cc.

References osl::NumEffectState::isCheck(), osl::Move::isPass(), osl::Move::isValidOrPass(), osl::hash::HashKey::newHashWithMove(), osl::Move::player(), push(), and osl::SimpleState::turn().

## Member Data Documentation

## continuous_check

CArray<std::vector<int>, 2> osl::RepetitionCounter::continuous_check

private

Definition at line 24 of file repetitionCounter.h.

Referenced by checkCount(), clear(), isAlmostSennichiteUnsafe(), isConsistent(), maybeEqual(), pop(), push(), and RepetitionCounter().

## hash_history

HashKeyStack osl::RepetitionCounter::hash_history

private

Definition at line 25 of file repetitionCounter.h.

Referenced by clear(), history(), isConsistent(), maybeEqual(), order(), pop(), push(), RepetitionCounter(), RepetitionCounter(), and RepetitionCounter().

## table

std::unique_ptr<Table> osl::RepetitionCounter::table

private

Definition at line 23 of file repetitionCounter.h.

Referenced by clear(), countRepetition(), distanceToSennichite(), getFirstMove(), getLastMove(), getRepetitions(), isConsistent(), isSennichite(), maybeEqual(), pop(), printMatches(), push(), RepetitionCounter(), RepetitionCounter(), and RepetitionCounter().

The documentation for this class was generated from the following files:

- repetitionCounter.h
- repetitionCounter.cc