osl::PieceStand Class Reference

片方の手番の持駒の枚数を記録するクラス. More...

`#include <pieceStand.h>`

## Public Member Functions

| PieceStand (unsigned int value=0)
| PieceStand (Player, const SimpleState &)
| PieceStand (int pawnCount, int lanceCount, int knightCount, int silverCount, int goldCount, int bishopCount, int rookCount, int kingCount)
void | add (Ptype type, unsigned int num=1)
void | sub (Ptype type, unsigned int num=1)
void | tryAdd (Ptype type)
| 加算可能なら加える.
bool | canAdd (Ptype type) const
void | trySub (Ptype type)
| 1枚以上持っていれば減らす
bool | atMostOneKind () const
| 一種類の駒しかない
void | addAtmostOnePiece (PieceStand const &ps)
| pieceStand同士の加算，減算.
void | subAtmostOnePiece (PieceStand const &ps)
unsigned int | get (Ptype type) const
void | carriesOff () const
void | carriesOn () const
unsigned int | testCarries () const
bool | isSuperiorOrEqualTo (PieceStand other) const
template<Player P>
bool | hasMoreThan (PieceStand other) const
| this と other が BLACK の持駒と考えた時に， this の方が同じか沢山持っていれば真.
bool | hasMoreThan (Player P, PieceStand other) const
unsigned int | getFlags () const
bool | any () const
| どれかの駒を一枚でも持っている
const PieceStand | max (PieceStand other) const
| 種類毎に this と other の持駒の多い方を取る
const PieceStand | max2 (PieceStand other) const
| 種類毎に this と other の持駒の多い方を取る (max のalternative)
const PieceStand | nextStand (Player pl, Move move) const
const PieceStand | nextStand (Move move) const
const PieceStand | previousStand (Player pl, Move move) const
const PieceStand | previousStand (Move move) const

## Static Public Attributes

static const CArray< Ptype, 7 > | order
| 持駒の表示で良く使われる順番.
static const unsigned int | carryMask = 0x48822224

## Private Member Functions

bool | carryUnchangedAfterAdd (const PieceStand &original, const PieceStand &other) const
bool | carryUnchangedAfterSub (const PieceStand &original, const PieceStand &other) const

## Private Attributes

unsigned int | flags

## Static Private Attributes

static const CArray< unsigned char, PTYPE_MAX+1 > | shift
static const CArray< unsigned char, PTYPE_MAX+1 > | mask

## Detailed Description

片方の手番の持駒の枚数を記録するクラス.

- bit field を使うべきか迷う
- 一応 king を持駒にして良いことにしておく レイアウト 長さ:index
- reserved : 1;31
- carry : 1;
- KING : 2;28
- carry : 1;
- GOLD : 3;24
- carry : 1;
- PAWN : 5;18
- carry : 1;
- LANCE : 3;14
- carry : 1;
- KNIGHT : 3;10
- carry : 1;
- SILVER : 3; 6
- carry : 1;
- BISHOP : 2; 3
- carry : 1;
- ROOK : 2; 0

== を軽くするために carry off の状態を基本とする

Definition at line 37 of file bits/pieceStand.h.

## Constructor & Destructor Documentation

## PieceStand() [1/3]

osl::PieceStand::PieceStand | ( | unsigned int | value = 0 | ) |

inline explicit

Definition at line 48 of file bits/pieceStand.h.

References flags.

Referenced by addAtmostOnePiece(), carryUnchangedAfterAdd(), carryUnchangedAfterSub(), hasMoreThan(), hasMoreThan(), isSuperiorOrEqualTo(), max(), max2(), nextStand(), nextStand(), previousStand(), previousStand(), and subAtmostOnePiece().

## PieceStand() [2/3]

osl::PieceStand::PieceStand | ( | Player | pl,
|  | const SimpleState & | state )

explicit

Definition at line 31 of file pieceStand.cc.

References add(), osl::SimpleState::countPiecesOnStand(), flags, and order.

## PieceStand() [3/3]

osl::PieceStand::PieceStand | ( | int | pawnCount,
|  | int | lanceCount,
|  | int | knightCount,
|  | int | silverCount,
|  | int | goldCount,
|  | int | bishopCount,
|  | int | rookCount,
|  | int | kingCount )

inline

Definition at line 52 of file bits/pieceStand.h.

References add(), osl::BISHOP, flags, osl::GOLD, osl::KING, osl::KNIGHT, osl::LANCE, osl::PAWN, osl::ROOK, and osl::SILVER.

## Member Function Documentation

## add()

void osl::PieceStand::add | ( | Ptype | type,
|  | unsigned int | num = 1 )

inline

Definition at line 68 of file bits/pieceStand.h.

References flags, osl::isBasic(), mask, shift, and testCarries().

Referenced by osl::checkmate::ProofPiecesUtil::addMonopolizedPieces(), osl::checkmate::Dfpn::attack(), osl::checkmate::ProofPieces::attack(), osl::checkmate::DisproofPieces::defense(), nextStand(), PieceStand(), PieceStand(), previousStand(), osl::checkmate::Dfpn::proofOracleAttack(), osl::PieceStandIO::readNumbers(), osl::checkmate::FixedDepthSolverExt::SetProofPieces::setAttackLeaf(), and tryAdd().

## addAtmostOnePiece()

void osl::PieceStand::addAtmostOnePiece | ( | PieceStand const & | ps | ) |

inline

pieceStand同士の加算，減算.

足して良いのは，carry が立っていないpiecestandで かつ，含まれる駒が高々1つ

Definition at line 108 of file bits/pieceStand.h.

References atMostOneKind(), carryUnchangedAfterAdd(), flags, getFlags(), PieceStand(), and testCarries().

Referenced by osl::hash::HashKey128::operator+=().

## any()

bool osl::PieceStand::any | ( |  | ) | const

inline

どれかの駒を一枚でも持っている

Definition at line 167 of file bits/pieceStand.h.

References flags.

## atMostOneKind()

bool osl::PieceStand::atMostOneKind | ( |  | ) | const

一種類の駒しかない

Definition at line 53 of file pieceStand.cc.

References osl::misc::BitOp::countBit(), and getFlags().

Referenced by addAtmostOnePiece(), and subAtmostOnePiece().

## canAdd()

bool osl::PieceStand::canAdd | ( | Ptype | type | ) | const

Definition at line 39 of file pieceStand.cc.

References get(), max(), and osl::Ptype_Table.

Referenced by tryAdd().

## carriesOff()

void osl::PieceStand::carriesOff | ( |  | ) | const

inline

Definition at line 135 of file bits/pieceStand.h.

References carryMask, and flags.

Referenced by isSuperiorOrEqualTo().

## carriesOn()

void osl::PieceStand::carriesOn | ( |  | ) | const

inline

Definition at line 136 of file bits/pieceStand.h.

References carryMask, and flags.

Referenced by isSuperiorOrEqualTo().

## carryUnchangedAfterAdd()

bool osl::PieceStand::carryUnchangedAfterAdd | ( | const PieceStand & | original,
|  | const PieceStand & | other ) const

private

Definition at line 59 of file pieceStand.cc.

References PieceStand(), and testCarries().

Referenced by addAtmostOnePiece().

## carryUnchangedAfterSub()

bool osl::PieceStand::carryUnchangedAfterSub | ( | const PieceStand & | original,
|  | const PieceStand & | other ) const

private

Definition at line 68 of file pieceStand.cc.

References PieceStand(), and testCarries().

Referenced by subAtmostOnePiece().

## get()

unsigned int osl::PieceStand::get | ( | Ptype | type | ) | const

inline

Definition at line 131 of file bits/pieceStand.h.

References flags, mask, and shift.

Referenced by osl::checkmate::ProofPiecesUtil::addMonopolizedPieces(), osl::checkmate::ProofPieces::attack(), canAdd(), osl::checkmate::DisproofPieces::defense(), nextStand(), osl::operator<<(), previousStand(), sub(), osl::hash::HashKey128::StandHash::toUint64(), trySub(), and osl::PieceStandIO::writeNumbers().

## getFlags()

unsigned int osl::PieceStand::getFlags | ( |  | ) | const

inline

Definition at line 165 of file bits/pieceStand.h.

References flags.

Referenced by addAtmostOnePiece(), atMostOneKind(), osl::hash::HashKey128::operator+=(), osl::hash::HashKey128::operator-=(), osl::operator<(), osl::operator==(), osl::hash::HashKey128::setPieceStand(), and subAtmostOnePiece().

## hasMoreThan() [1/2]

template<Player P>

bool osl::PieceStand::hasMoreThan | ( | PieceStand | other | ) | const

inline

this と other が BLACK の持駒と考えた時に， this の方が同じか沢山持っていれば真.

Definition at line 151 of file bits/pieceStand.h.

References osl::BLACK, isSuperiorOrEqualTo(), and PieceStand().

Referenced by hasMoreThan().

## hasMoreThan() [2/2]

bool osl::PieceStand::hasMoreThan | ( | Player | P,
|  | PieceStand | other ) const

inline

Definition at line 158 of file bits/pieceStand.h.

References osl::BLACK, hasMoreThan(), and PieceStand().

## isSuperiorOrEqualTo()

bool osl::PieceStand::isSuperiorOrEqualTo | ( | PieceStand | other | ) | const

inline

Definition at line 138 of file bits/pieceStand.h.

References carriesOff(), carriesOn(), carryMask, flags, and PieceStand().

Referenced by osl::checkmate::ProofTreeDepthDfpn::Table::expectMoreDepth(), osl::checkmate::DfpnPathList::find(), osl::checkmate::DualDfpn::findProof(), osl::checkmate::DfpnTable::List::findProofOracle(), hasMoreThan(), osl::checkmate::DfpnTable::List::probe(), and osl::checkmate::DfpnTable::List::showProofOracles().

## max()

const PieceStand osl::PieceStand::max | ( | PieceStand | other | ) | const

inline

種類毎に this と other の持駒の多い方を取る

Definition at line 171 of file bits/pieceStand.h.

References carryMask, flags, and PieceStand().

Referenced by osl::checkmate::DfpnTable::List::addDag(), canAdd(), osl::checkmate::DfpnTable::List::store(), and osl::checkmate::FixedDepthSolverExt::SetProofPieces::updateMax().

## max2()

const PieceStand osl::PieceStand::max2 | ( | PieceStand | other | ) | const

inline

種類毎に this と other の持駒の多い方を取る (max のalternative)

Definition at line 187 of file bits/pieceStand.h.

References carryMask, flags, and PieceStand().

## nextStand() [1/2]

const PieceStand osl::PieceStand::nextStand | ( | Move | move | ) | const

inline

Definition at line 222 of file bits/pieceStand.h.

References nextStand(), PieceStand(), and osl::Move::player().

## nextStand() [2/2]

const PieceStand osl::PieceStand::nextStand | ( | Player | pl,
|  | Move | move ) const

inline

Definition at line 203 of file bits/pieceStand.h.

References add(), osl::Move::capturePtype(), get(), osl::Move::isDrop(), osl::Move::isNormal(), PieceStand(), osl::Move::player(), osl::Move::ptype(), sub(), and osl::unpromote().

Referenced by nextStand(), and osl::checkmate::ProofTreeDepthDfpn::orNode().

## previousStand() [1/2]

const PieceStand osl::PieceStand::previousStand | ( | Move | move | ) | const

inline

Definition at line 246 of file bits/pieceStand.h.

References PieceStand(), osl::Move::player(), and previousStand().

## previousStand() [2/2]

const PieceStand osl::PieceStand::previousStand | ( | Player | pl,
|  | Move | move ) const

inline

Definition at line 226 of file bits/pieceStand.h.

References add(), osl::Move::capturePtype(), get(), osl::Move::isDrop(), osl::Move::isNormal(), PieceStand(), osl::Move::player(), osl::Move::ptype(), sub(), and osl::unpromote().

Referenced by osl::checkmate::Dfpn::findDagSource(), previousStand(), and osl::checkmate::DualDfpn::writeRootHistory().

## sub()

void osl::PieceStand::sub | ( | Ptype | type,
|  | unsigned int | num = 1 )

inline

Definition at line 75 of file bits/pieceStand.h.

References flags, get(), osl::isBasic(), mask, and shift.

Referenced by nextStand(), previousStand(), and trySub().

## subAtmostOnePiece()

void osl::PieceStand::subAtmostOnePiece | ( | PieceStand const & | ps | ) |

inline

Definition at line 118 of file bits/pieceStand.h.

References atMostOneKind(), carryUnchangedAfterSub(), flags, getFlags(), PieceStand(), and testCarries().

Referenced by osl::hash::HashKey128::operator-=().

## testCarries()

unsigned int osl::PieceStand::testCarries | ( |  | ) | const

inline

Definition at line 137 of file bits/pieceStand.h.

References carryMask, and flags.

Referenced by add(), addAtmostOnePiece(), carryUnchangedAfterAdd(), carryUnchangedAfterSub(), osl::operator<(), osl::operator==(), and subAtmostOnePiece().

## tryAdd()

void osl::PieceStand::tryAdd | ( | Ptype | type | ) |

加算可能なら加える.

速度が必要なところでは使ってないので .cc に移動．

Definition at line 47 of file pieceStand.cc.

References add(), and canAdd().

## trySub()

void osl::PieceStand::trySub | ( | Ptype | type | ) |

inline

1枚以上持っていれば減らす

Definition at line 92 of file bits/pieceStand.h.

References get(), and sub().

Referenced by osl::checkmate::ProofPieces::attack(), and osl::checkmate::DisproofPieces::defense().

## Member Data Documentation

## carryMask

const unsigned int osl::PieceStand::carryMask = 0x48822224

static

Definition at line 42 of file bits/pieceStand.h.

Referenced by carriesOff(), carriesOn(), isSuperiorOrEqualTo(), max(), max2(), and testCarries().

## flags

unsigned int osl::PieceStand::flags

mutable private

Definition at line 46 of file bits/pieceStand.h.

Referenced by add(), addAtmostOnePiece(), any(), carriesOff(), carriesOn(), get(), getFlags(), isSuperiorOrEqualTo(), max(), max2(), PieceStand(), PieceStand(), PieceStand(), sub(), subAtmostOnePiece(), and testCarries().

## mask

const CArray< unsigned char, PTYPE_MAX+1 > osl::PieceStand::mask

static private

Initial value:
=
{{
0,0,0,0,0,0,0,0,
(1<<2)-1, (1<<3)-1, (1<<5)-1, (1<<3)-1, (1<<3)-1, (1<<3)-1, (1<<2)-1, (1<<2)-1
}}

Definition at line 45 of file bits/pieceStand.h.

Referenced by add(), get(), and sub().

## order

const CArray< Ptype, 7 > osl::PieceStand::order

static

Initial value:
=
{{
ROOK, BISHOP, GOLD, SILVER, KNIGHT, LANCE, PAWN,
}}
osl::ROOK
@ ROOK
Definition basic_type.h:100
osl::BISHOP
@ BISHOP
Definition basic_type.h:99
osl::PAWN
@ PAWN
Definition basic_type.h:95
osl::KNIGHT
@ KNIGHT
Definition basic_type.h:97
osl::SILVER
@ SILVER
Definition basic_type.h:98
osl::GOLD
@ GOLD
Definition basic_type.h:94
osl::LANCE
@ LANCE
Definition basic_type.h:96

持駒の表示で良く使われる順番.

KINGや成駒は -1

Definition at line 41 of file bits/pieceStand.h.

Referenced by osl::checkmate::ProofPiecesUtil::addMonopolizedPieces(), osl::eval::ml::NonPawnPieceStandTurn::eval(), osl::eval::ml::PieceStand::eval(), osl::SimpleState::initPawnMask(), osl::SimpleState::isConsistent(), osl::record::KisenPlusFile::load(), osl::move_probability::SacrificeAttack::match(), osl::progress::ml::NewProgress::NewProgress(), osl::eval::ml::OpenMidEndingEval::OpenMidEndingEval(), osl::operator<<(), PieceStand(), osl::record::KanjiPrint::print(), osl::PieceStandIO::readNumbers(), osl::record::KisenWriter::save(), osl::eval::ml::PieceStandY::setUp(), osl::record::myshogi::show(), osl::usi::show(), osl::move_probability::MoveInfo::standIndex(), osl::progress::ml::NewProgress::updatePieceStand7(), and osl::PieceStandIO::writeNumbers().

## shift

const CArray< unsigned char, PTYPE_MAX+1 > osl::PieceStand::shift

static private

Initial value:
=
{{
0,0,0,0,0,0,0,0,
28, 24, 18, 14, 10, 6, 3, 0,
}}

Definition at line 44 of file bits/pieceStand.h.

Referenced by add(), get(), and sub().

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

- bits/pieceStand.h
- pieceStand.cc