All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | Static Private Attributes
osl::PieceStand Class Reference

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

#include <pieceStand.h>

Collaboration diagram for osl::PieceStand:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 PieceStand (unsigned int value=0)
 PieceStand (Player, const state::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

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

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

Definition at line 40 of file pieceStand.h.


Constructor & Destructor Documentation

osl::PieceStand::PieceStand ( unsigned int  value = 0) [inline, explicit]

Definition at line 51 of file pieceStand.h.

Referenced by max(), and max2().

osl::PieceStand::PieceStand ( Player  ,
const state::SimpleState  
) [explicit]
osl::PieceStand::PieceStand ( int  pawnCount,
int  lanceCount,
int  knightCount,
int  silverCount,
int  goldCount,
int  bishopCount,
int  rookCount,
int  kingCount 
) [inline]

Member Function Documentation

void osl::PieceStand::add ( Ptype  type,
unsigned int  num = 1 
) [inline]
void osl::PieceStand::addAtmostOnePiece ( PieceStand const &  ps) [inline]

pieceStand同士の加算,減算.

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

Definition at line 111 of file pieceStand.h.

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

Referenced by osl::hash::HashKey128::operator+=(), and osl::hash::GeneralHashKey< BoardKeyBase >::operator+=().

bool osl::PieceStand::any ( ) const [inline]

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

Definition at line 170 of file pieceStand.h.

References flags.

一種類の駒しかない

Definition at line 57 of file pieceStand.cc.

References osl::misc::BitOp::countBit().

Referenced by addAtmostOnePiece(), and subAtmostOnePiece().

bool osl::PieceStand::canAdd ( Ptype  type) const
void osl::PieceStand::carriesOff ( ) const [inline]

Definition at line 138 of file pieceStand.h.

References carryMask, and flags.

Referenced by isSuperiorOrEqualTo().

void osl::PieceStand::carriesOn ( ) const [inline]

Definition at line 139 of file pieceStand.h.

References carryMask, and flags.

Referenced by isSuperiorOrEqualTo().

bool osl::PieceStand::carryUnchangedAfterAdd ( const PieceStand original,
const PieceStand other 
) const [private]

Definition at line 64 of file pieceStand.cc.

References testCarries().

Referenced by addAtmostOnePiece().

bool osl::PieceStand::carryUnchangedAfterSub ( const PieceStand original,
const PieceStand other 
) const [private]

Definition at line 73 of file pieceStand.cc.

References testCarries().

Referenced by subAtmostOnePiece().

unsigned int osl::PieceStand::get ( Ptype  type) const [inline]
unsigned int osl::PieceStand::getFlags ( ) const [inline]
template<Player P>
bool osl::PieceStand::hasMoreThan ( PieceStand  other) const [inline]

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

Definition at line 154 of file pieceStand.h.

References osl::BLACK, and isSuperiorOrEqualTo().

Referenced by osl::search::DominanceCheck::detect(), and osl::ntesuki::NtesukiRecord::isBetterFor().

bool osl::PieceStand::hasMoreThan ( Player  P,
PieceStand  other 
) const [inline]

Definition at line 161 of file pieceStand.h.

References osl::BLACK.

bool osl::PieceStand::isSuperiorOrEqualTo ( PieceStand  other) const [inline]
const PieceStand osl::PieceStand::max ( PieceStand  other) const [inline]
const PieceStand osl::PieceStand::max2 ( PieceStand  other) const [inline]

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

Definition at line 190 of file pieceStand.h.

References carryMask, flags, and PieceStand().

const PieceStand osl::PieceStand::nextStand ( Player  pl,
Move  move 
) const [inline]
const PieceStand osl::PieceStand::nextStand ( Move  move) const [inline]

Definition at line 225 of file pieceStand.h.

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

const PieceStand osl::PieceStand::previousStand ( Player  pl,
Move  move 
) const [inline]
const PieceStand osl::PieceStand::previousStand ( Move  move) const [inline]

Definition at line 249 of file pieceStand.h.

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

void osl::PieceStand::sub ( Ptype  type,
unsigned int  num = 1 
) [inline]
void osl::PieceStand::subAtmostOnePiece ( PieceStand const &  ps) [inline]
unsigned int osl::PieceStand::testCarries ( ) const [inline]

加算可能なら加える.

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

Definition at line 51 of file pieceStand.cc.

void osl::PieceStand::trySub ( Ptype  type) [inline]

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

Definition at line 95 of file pieceStand.h.

References sub().

Referenced by osl::ntesuki::NtesukiRecord::calcProofPiecesOr(), and osl::ntesuki::NtesukiRecord::setDisproofPieces().


Member Data Documentation

const unsigned int osl::PieceStand::carryMask = 0x48822224 [static]

Definition at line 45 of file pieceStand.h.

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

unsigned int osl::PieceStand::flags [mutable, private]
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 48 of file pieceStand.h.

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

const CArray< Ptype, 7 > osl::PieceStand::order [static]
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 47 of file pieceStand.h.

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


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines