#include <simpleState.h>


Public Member Functions | |
| SimpleState () | |
| SimpleState (Handicap h) | |
| virtual | ~SimpleState () |
| void | init () |
| 盤面が空の状態に初期化 More... | |
| void | init (Handicap h) |
| ハンディに応じた初期状態に初期化 More... | |
| void | initPawnMask () |
| const Piece | pieceOf (int num) const |
| void | setPieceOf (int num, Piece p) |
| template<Player P> | |
| const Piece | kingPiece () const |
| const Piece | kingPiece (Player P) const |
| template<Player P> | |
| Square | kingSquare () const |
| Square | kingSquare (Player player) const |
| template<Ptype PTYPE> | |
| const Piece | nth (int n) const |
| unpromote(PTYPE)のn番目の駒を帰す. More... | |
| void | setBoard (Square sq, Piece piece) |
| const PieceMask & | standMask (Player p) const |
| const PieceMask & | usedMask () const |
| bool | isOffBoard (int num) const |
| void | clearPawn (Player pl, Square sq) |
| (internal) More... | |
| void | setPawn (Player pl, Square sq) |
| (internal) More... | |
| bool | isPawnMaskSet (Player player, int x) const |
| template<Player P> | |
| bool | isPawnMaskSet (int x) const |
| bool | canDropPawnTo (Player player, int x) const |
| xの筋に歩を打てる More... | |
| void | setPiece (Player player, Square sq, Ptype ptype) |
| void | setPieceAll (Player player) |
| const Piece | pieceAt (Square sq) const |
| const Piece | operator[] (Square sq) const |
| const Piece * | getPiecePtr (Square sq) const |
| const Piece | pieceOnBoard (Square sq) const |
| bool | isOnBoard (int num) const |
| int | countPiecesOnStand (Player pl, Ptype ptype) const |
| 持駒の枚数を数える More... | |
| template<Ptype Type> | |
| int | countPiecesOnStand (Player pl) const |
| 後方互換 More... | |
| bool | hasPieceOnStand (Player player, Ptype ptype) const |
| template<Ptype T> | |
| bool | hasPieceOnStand (Player P) const |
| Piece | nextPiece (Square cur, Offset diff) const |
| diff方向にあるPiece を求める. More... | |
| void | setTurn (Player player) |
| Player | turn () const |
| void | changeTurn () |
| 手番を変更する More... | |
| bool | isConsistent (bool show_error=true) const |
| template<bool show_error> | |
| bool | isAlmostValidMove (Move move) const |
| エラー表示をするかどうかをtemplateパラメータにした高速化版 More... | |
| bool | isAlmostValidMove (Move move, bool show_error=true) const |
| 合法手かどうかを簡単に検査する.局面に依存するチェックのみ. ルール上指せない手である可能性がある場合は,isValidMove を用いる. More... | |
| bool | isValidMove (Move move, bool show_error=true) const |
| 合法手かどうかを検査する. isValidMoveByRule, isAlmostValidMove をおこなう. 玉の素抜きや王手を防いでいるか, 千日手,打歩詰かどうかは検査しない. More... | |
| bool | isEmptyBetween (Square from, Square to, Offset offset, bool pieceExistsAtTo=false) const |
| bool | isEmptyBetween (Square from, Square to, bool noSpaceAtTo=false) const |
| bool | dump () const |
| dump: 自分を cerr に表示する。abort 前などにデバッグに使う More... | |
| const SimpleState | emulateCapture (Piece from, Player new_owner) const |
| from で表現されたPieceをnew_ownerの持駒にした局面を作る. More... | |
| const SimpleState | emulateHandPiece (Player from, Player to, Ptype ptype) const |
| from からto に ptypeの持駒を一枚渡した局面を作る. More... | |
| const SimpleState | rotate180 () const |
| const SimpleState | flipHorizontal () const |
| template<bool show_error> | |
| bool | isAlmostValidDrop (Move move) const |
| template<bool show_error> | |
| bool | testValidityOtherThanEffect (Move move) const |
| template<bool show_error> | |
| bool | isAlmostValidMove (Move move) const |
Static Public Member Functions | |
| template<Ptype PTYPE> | |
| static int | nthLimit () |
| static bool | isValidMoveByRule (Move move, bool show_error) |
| 盤面以外の部分の反則のチェック More... | |
Static Public Attributes | |
| static const bool | hasPawnMask =true |
Protected Member Functions | |
| PieceMask & | standMask (Player p) |
| template<bool show_error> | |
| bool | isAlmostValidDrop (Move move) const |
| template<bool show_error> | |
| bool | testValidityOtherThanEffect (Move move) const |
Protected Attributes | |
| CArray< Piece, Square::SIZE > | board |
| CArray< Piece, Piece::SIZE > | pieces |
| 全てのpieceが登録されている More... | |
| CArray< PieceMask, 2 > | stand_mask |
| CArray< BitXmask, 2 > | pawnMask |
| CArray< CArray< char, PTYPE_SIZE-PTYPE_BASIC_MIN >, 2 > | stand_count |
| Player | player_to_move |
| 手番 More... | |
| PieceMask | used_mask |
Private Types | |
| typedef SimpleState | state_t |
Private Member Functions | |
| int | countPiecesOnStandBit (Player pl, Ptype ptype) const |
Friends | |
| std::ostream & | operator<< (std::ostream &os, const SimpleState &state) |
| bool | operator== (const SimpleState &st1, const SimpleState &st2) |
| 盤上の駒のみを比較する(持ち駒は見ない). More... | |
Definition at line 37 of file simpleState.h.
|
private |
Definition at line 42 of file simpleState.h.
|
explicit |
Definition at line 14 of file simpleState.cc.
|
explicit |
Definition at line 18 of file simpleState.cc.
|
virtual |
Definition at line 114 of file simpleState.cc.
|
inline |
|
inline |
手番を変更する
Definition at line 229 of file simpleState.h.
References osl::alt(), and player_to_move.
Referenced by main(), osl::state::NumEffectState::makeMovePass(), and osl::state::NumEffectState::makeUnmakePass().
持駒の枚数を数える
Definition at line 185 of file simpleState.h.
References osl::isBasic(), osl::PTYPE_BASIC_MIN, and stand_count.
Referenced by osl::enter_king::countPiecePointsOnStand(), countPiecesOnStand(), osl::eval::ml::PieceStand::eval(), hasPieceOnStand(), PieceStandPredicate::match(), osl::record::KanjiPrint::print(), and osl::eval::ml::PieceStandY::updateResult().
|
inline |
Definition at line 202 of file simpleState.h.
References osl::PtypeTable::getMaskLow(), osl::Ptype_Table, and standMask().
| bool osl::SimpleState::dump | ( | ) | const |
dump: 自分を cerr に表示する。abort 前などにデバッグに使う
Definition at line 452 of file simpleState.cc.
from で表現されたPieceをnew_ownerの持駒にした局面を作る.
Definition at line 462 of file simpleState.cc.
References osl::Piece::owner(), osl::Piece::ptype(), osl::Piece::square(), and osl::unpromote().
| const osl::SimpleState osl::SimpleState::emulateHandPiece | ( | Player | from, |
| Player | to, | ||
| Ptype | ptype | ||
| ) | const |
from からto に ptypeの持駒を一枚渡した局面を作る.
Definition at line 482 of file simpleState.cc.
References osl::alt(), osl::Piece::isOnBoard(), osl::Piece::owner(), osl::Piece::ptype(), and osl::Piece::square().
| const osl::state::SimpleState osl::state::SimpleState::flipHorizontal | ( | ) | const |
Definition at line 520 of file simpleState.cc.
References osl::Square::flipHorizontal(), initPawnMask(), osl::Piece::owner(), osl::Piece::ptype(), setPiece(), setTurn(), and osl::Piece::square().
Definition at line 172 of file simpleState.h.
References board, and osl::Square::index().
Definition at line 194 of file simpleState.h.
References countPiecesOnStand().
|
inline |
Definition at line 198 of file simpleState.h.
References countPiecesOnStand().
| void osl::SimpleState::init | ( | ) |
盤面が空の状態に初期化
Definition at line 46 of file simpleState.cc.
References osl::BLACK, osl::PieceTable::getPtypeOf(), osl::Piece_Table, and osl::WHITE.
| void osl::SimpleState::init | ( | Handicap | h) |
ハンディに応じた初期状態に初期化
Definition at line 69 of file simpleState.cc.
References osl::BISHOP, osl::BLACK, osl::GOLD, osl::HIRATE, osl::KING, osl::KNIGHT, osl::LANCE, osl::PAWN, osl::ROOK, osl::SILVER, and osl::WHITE.
| void osl::SimpleState::initPawnMask | ( | ) |
Definition at line 22 of file simpleState.cc.
References osl::BLACK, osl::Square::isPieceStand(), osl::Piece::isPromotedNotKingGold(), order, osl::Piece::owner(), osl::PTYPE_BASIC_MIN, osl::Piece::square(), osl::WHITE, and osl::Square::x().
Referenced by flipHorizontal(), and rotate180().
| bool osl::state::SimpleState::isAlmostValidDrop | ( | Move | move) | const |
Definition at line 10 of file simpleState.tcc.
References osl::Move::from(), osl::Piece::isEmpty(), osl::Square::isPieceStand(), osl::PAWN, osl::Move::player(), osl::Move::ptype(), and osl::Move::to().
|
protected |
| bool osl::state::SimpleState::isAlmostValidMove | ( | Move | move) | const |
エラー表示をするかどうかをtemplateパラメータにした高速化版
| bool osl::state::SimpleState::isAlmostValidMove | ( | Move | move, |
| bool | show_error = true |
||
| ) | const |
合法手かどうかを簡単に検査する.局面に依存するチェックのみ. ルール上指せない手である可能性がある場合は,isValidMove を用いる.
局面に依存する検査でも,玉の素抜きや王手を防いでいるか, 千日手,打歩詰かどうかは検査しない.
| bool osl::state::SimpleState::isAlmostValidMove | ( | Move | move) | const |
Definition at line 334 of file simpleState.cc.
References osl::Move::from(), osl::PtypeTable::getEffect(), osl::EffectContent::hasUnblockableEffect(), osl::Square::isPieceStand(), osl::Move::isValid(), osl::EffectContent::offset(), osl::Move::player(), osl::Ptype_Table, osl::Piece::ptypeO(), osl::Move::to(), and osl::Offset::zero().
| bool osl::SimpleState::isConsistent | ( | bool | show_error = true) | const |
Definition at line 159 of file simpleState.cc.
References osl::BLACK, osl::PieceTable::getPtypeOf(), osl::Piece::isEmpty(), osl::Square::isOnBoard(), osl::Piece::isOnBoard(), osl::Piece::isPiece(), osl::Square::isPieceStand(), osl::Piece::isPromoted(), osl::Piece::isPromotedNotKingGold(), osl::KING, osl::Piece::number(), order, osl::Piece::owner(), osl::Piece_Table, osl::playerToIndex(), osl::Piece::ptype(), osl::Piece::square(), osl::Square::squareForBlack(), osl::unpromote(), and osl::WHITE.
Referenced by osl::state::NumEffectState::isConsistent(), and osl::state::operator==().
|
inline |
| from | - マスの位置 |
| to | - マスの位置 |
| offset | - fromからtoへのshort offset fromとtoがクイーンで利きがある位置関係にあるという前提 で,間が全部空白かをチェック |
| pieceExistsAtTo | - toに必ず駒がある (toが空白でも動く) |
Definition at line 270 of file simpleState.h.
References osl::Board_Table, osl::BoardTable::getShortOffset(), osl::Piece::isEmpty(), osl::Square::isOnBoard(), pieceAt(), and osl::Offset::zero().
Referenced by osl::state::NumEffectState::hasEffectIf(), and isEmptyBetween().
|
inline |
| from | - マスの位置 |
| to | - マスの位置 fromとtoがクイーンで利きがある位置関係にあるという前提 で,間が全部空白かをチェック |
Definition at line 296 of file simpleState.h.
References osl::Board_Table, osl::BoardTable::getShortOffset(), isEmptyBetween(), and osl::Square::isOnBoard().
|
inline |
Definition at line 135 of file simpleState.h.
References osl::BLACK, standMask(), and osl::WHITE.
|
inline |
Definition at line 179 of file simpleState.h.
References osl::Piece::isOnBoard(), and pieceOf().
Referenced by osl::state::NumEffectState::NumEffectState().
|
inline |
|
inline |
Definition at line 155 of file simpleState.h.
References isPawnMaskSet().
Referenced by isPawnMaskSet().
| bool osl::SimpleState::isValidMove | ( | Move | move, |
| bool | show_error = true |
||
| ) | const |
合法手かどうかを検査する. isValidMoveByRule, isAlmostValidMove をおこなう. 玉の素抜きや王手を防いでいるか, 千日手,打歩詰かどうかは検査しない.
Definition at line 437 of file simpleState.cc.
References osl::Move::isValid(), and osl::Move::player().
|
static |
盤面以外の部分の反則のチェック
Definition at line 374 of file simpleState.cc.
References osl::PtypeTable::canDropTo(), osl::canPromote(), osl::Square::canPromote(), osl::Move::from(), osl::PtypeTable::getEffect(), osl::getPtype(), osl::EffectContent::hasUnblockableEffect(), osl::isBasic(), osl::Move::isNormal(), osl::isPromoted(), osl::Move::isPromotion(), osl::EffectContent::offset(), osl::Move::oldPtypeO(), osl::Move::player(), osl::Move::ptype(), osl::Ptype_Table, osl::Move::to(), osl::unpromote(), and osl::Offset::zero().
|
inline |
Definition at line 86 of file simpleState.h.
References pieceOf().
Referenced by osl::eval::ml::King8Effect::eval().
Definition at line 89 of file simpleState.h.
References osl::BLACK, and osl::isValid().
|
inline |
Definition at line 97 of file simpleState.h.
Referenced by osl::eval::ml::King25Effect::countEffectAndPieces(), osl::eval::ml::King25EffectBoth::countEffectAndPiecesBoth(), osl::eval::ml::KingXBlockedBase::eval(), osl::eval::ml::KingXBlockedYBase::eval(), osl::eval::ml::King25EmptyAbs< Opening >::evalOne(), osl::eval::ml::King25EmptyAbs< Opening >::evalWithUpdate(), osl::eval::ml::King8EffectBase::evalWithUpdateCommon(), osl::state::NumEffectState::findCheckPiece(), osl::enter_king::SimplePredictor::getProbability(), osl::enter_king::SimplePredictor::getProbability27(), osl::state::NumEffectState::inCheck(), main(), and osl::state::NumEffectState::recalcPinOpen().
Definition at line 100 of file simpleState.h.
References osl::BLACK, and osl::isValid().
diff方向にあるPiece を求める.
Definition at line 211 of file simpleState.h.
References osl::Piece::EMPTY(), pieceAt(), and osl::Offset::zero().
|
inline |
unpromote(PTYPE)のn番目の駒を帰す.
駒番号に依存するので順番は不定.
Definition at line 117 of file simpleState.h.
References pieceOf().
|
inlinestatic |
Definition at line 108 of file simpleState.h.
Definition at line 171 of file simpleState.h.
References pieceAt().
| sq | は isOnboardを満たす Square の12近傍(8近傍+桂馬の利き) ! isOnBoard(sq) の場合は PIECE_EDGE を返す |
Definition at line 170 of file simpleState.h.
References board, and osl::Square::index().
Referenced by osl::eval::ml::SilverFeatures::canRetreat(), osl::eval::ml::GoldFeatures::canRetreat(), osl::eval::ml::KnightAdvance::cantAdvance(), osl::eval::ml::King25EffectBoth::countEffectAndPiecesBoth(), osl::eval::ml::King25EmptyAbs< Opening >::evalOne(), osl::eval::ml::PawnAdvanceAll::evalWithUpdateBang(), osl::state::NumEffectState::forEachEffectOfPieceDir(), osl::state::NumEffectState::forEachEffectOfPieceLongDir(), isEmptyBetween(), osl::state::NumEffectState::makePinOpenDir(), osl::state::NumEffectState::makeUnmakeMove(), nextPiece(), osl::state::operator==(), operator[](), pieceOnBoard(), osl::state::NumEffectState::recalcPinOpen(), osl::search::StateElements::validCaptureMove(), and osl::search::StateElements::validSimpleMove().
|
inline |
Definition at line 79 of file simpleState.h.
References pieces.
Referenced by osl::state::NumEffectState::findAttackAt(), osl::state::NumEffectState::findAttackAtStrict(), osl::state::NumEffectState::findAttackNotBy(), osl::state::NumEffectState::findLongAttackAt(), osl::state::NumEffectState::forEachEffect(), osl::state::NumEffectState::forEachOnBoard(), osl::state::NumEffectState::forEachOnBoardPtypeStrict(), osl::state::NumEffectState::hasEffectAt(), osl::state::NumEffectState::hasEffectInDirection(), osl::state::NumEffectState::isConsistent(), isOnBoard(), kingPiece(), nth(), osl::state::NumEffectState::NumEffectState(), osl::state::NumEffectState::pinAttacker(), and rotate180().
Definition at line 173 of file simpleState.h.
References osl::Square::isOnBoard(), and pieceAt().
Referenced by osl::ntesuki::NtesukiSimulationSearcher::adjustMove(), osl::enter_king::countPiecePointsInRange(), osl::state::NumEffectState::findLongAttackAt(), osl::state::operator<<(), and osl::record::KanjiPrint::print().
| const osl::state::SimpleState osl::state::SimpleState::rotate180 | ( | ) | const |
Definition at line 507 of file simpleState.cc.
References osl::alt(), initPawnMask(), osl::Piece::owner(), pieceOf(), osl::Piece::ptype(), osl::Square::rotate180Safe(), setPiece(), setTurn(), osl::Piece::square(), turn(), and usedMask().
Definition at line 122 of file simpleState.h.
References board, and osl::Square::index().
Definition at line 116 of file simpleState.cc.
References osl::PieceTable::getPtypeOf(), osl::Square::isPieceStand(), osl::KING, osl::PAWN, osl::Piece_Table, osl::playerToIndex(), and osl::unpromote().
Referenced by flipHorizontal(), and rotate180().
| void osl::SimpleState::setPieceAll | ( | Player | player) |
Definition at line 141 of file simpleState.cc.
References osl::alt(), osl::PieceTable::getPtypeOf(), osl::Piece_Table, and osl::playerToIndex().
|
inline |
Definition at line 82 of file simpleState.h.
References pieces.
|
inline |
Definition at line 220 of file simpleState.h.
References player_to_move.
Referenced by flipHorizontal(), and rotate180().
|
inlineprotected |
Definition at line 127 of file simpleState.h.
References stand_mask.
Referenced by countPiecesOnStandBit(), and isOffBoard().
|
inline |
Definition at line 131 of file simpleState.h.
References stand_mask.
| bool osl::state::SimpleState::testValidityOtherThanEffect | ( | Move | move) | const |
Definition at line 37 of file simpleState.tcc.
References osl::Move::capturePtype(), osl::Move::from(), osl::Piece::isEmpty(), osl::Piece::isPromotedNotKingGold(), osl::Move::isPromotion(), osl::Piece::owner(), osl::Piece::ptype(), osl::Move::ptype(), osl::Move::to(), and osl::unpromote().
|
protected |
|
inline |
Definition at line 223 of file simpleState.h.
References player_to_move.
Referenced by osl::state::NumEffectState::inCheck(), main(), osl::state::NumEffectState::makeUnmakeMove(), osl::state::operator<<(), osl::state::operator==(), osl::record::KanjiPrint::print(), qsearch(), and rotate180().
|
inline |
|
friend |
|
friend |
盤上の駒のみを比較する(持ち駒は見ない).
なお、駒番に非依存な局面比較をしたい場合は、osl::record::CompactBoardや osl::hash::HashKeyを用いる.
|
protected |
Definition at line 50 of file simpleState.h.
Referenced by osl::state::NumEffectState::copyFrom(), getPiecePtr(), pieceAt(), and setBoard().
|
static |
Definition at line 44 of file simpleState.h.
|
protected |
Definition at line 60 of file simpleState.h.
Referenced by clearPawn(), osl::state::NumEffectState::copyFrom(), isPawnMaskSet(), osl::state::operator==(), and setPawn().
|
protected |
全てのpieceが登録されている
Definition at line 58 of file simpleState.h.
Referenced by osl::state::NumEffectState::copyFrom(), osl::state::NumEffectState::findAttackNotBy(), osl::state::NumEffectState::findCheapAttackNotBy(), osl::state::NumEffectState::forEachEffectNotBy(), pieceOf(), and setPieceOf().
|
protected |
手番
Definition at line 64 of file simpleState.h.
Referenced by changeTurn(), osl::state::NumEffectState::copyFrom(), setTurn(), and turn().
|
protected |
Definition at line 61 of file simpleState.h.
Referenced by osl::state::NumEffectState::copyFrom(), and countPiecesOnStand().
|
protected |
Definition at line 59 of file simpleState.h.
Referenced by osl::state::NumEffectState::copyFrom(), and standMask().
|
protected |
Definition at line 65 of file simpleState.h.
Referenced by osl::state::NumEffectState::copyFrom(), and usedMask().
1.8.4