All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | Private Types | Private Member Functions | Friends | List of all members
osl::state::SimpleState Class Reference

#include <simpleState.h>

Inheritance diagram for osl::state::SimpleState:
Inheritance graph
[legend]
Collaboration diagram for osl::state::SimpleState:
Collaboration graph
[legend]

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 PiecegetPiecePtr (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::SIZEboard
 
CArray< Piece, Piece::SIZEpieces
 全ての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...
 

Detailed Description

Definition at line 37 of file simpleState.h.

Member Typedef Documentation

Definition at line 42 of file simpleState.h.

Constructor & Destructor Documentation

osl::SimpleState::SimpleState ( )
explicit

Definition at line 14 of file simpleState.cc.

osl::SimpleState::SimpleState ( Handicap  h)
explicit

Definition at line 18 of file simpleState.cc.

osl::SimpleState::~SimpleState ( )
virtual

Definition at line 114 of file simpleState.cc.

Member Function Documentation

bool osl::state::SimpleState::canDropPawnTo ( Player  player,
int  x 
) const
inline

xの筋に歩を打てる

Definition at line 158 of file simpleState.h.

References isPawnMaskSet().

void osl::state::SimpleState::changeTurn ( )
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().

void osl::state::SimpleState::clearPawn ( Player  pl,
Square  sq 
)
inline

(internal)

Definition at line 141 of file simpleState.h.

References pawnMask.

int osl::state::SimpleState::countPiecesOnStand ( Player  pl,
Ptype  ptype 
) const
inline
template<Ptype Type>
int osl::state::SimpleState::countPiecesOnStand ( Player  pl) const
inline

後方互換

Definition at line 191 of file simpleState.h.

References countPiecesOnStand().

int osl::state::SimpleState::countPiecesOnStandBit ( Player  pl,
Ptype  ptype 
) const
inlineprivate

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.

const osl::SimpleState osl::SimpleState::emulateCapture ( Piece  from,
Player  new_owner 
) const

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
const Piece* osl::state::SimpleState::getPiecePtr ( Square  sq) const
inline

Definition at line 172 of file simpleState.h.

References board, and osl::Square::index().

bool osl::state::SimpleState::hasPieceOnStand ( Player  player,
Ptype  ptype 
) const
inline

Definition at line 194 of file simpleState.h.

References countPiecesOnStand().

template<Ptype T>
bool osl::state::SimpleState::hasPieceOnStand ( Player  P) const
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 ( )
template<bool show_error>
bool osl::state::SimpleState::isAlmostValidDrop ( Move  move) const
template<bool show_error>
bool osl::state::SimpleState::isAlmostValidDrop ( Move  move) const
protected
template<bool show_error>
bool osl::state::SimpleState::isAlmostValidMove ( Move  move) const

エラー表示をするかどうかをtemplateパラメータにした高速化版

bool osl::state::SimpleState::isAlmostValidMove ( Move  move,
bool  show_error = true 
) const

合法手かどうかを簡単に検査する.局面に依存するチェックのみ. ルール上指せない手である可能性がある場合は,isValidMove を用いる.

局面に依存する検査でも,玉の素抜きや王手を防いでいるか, 千日手,打歩詰かどうかは検査しない.

template<bool show_error>
bool osl::state::SimpleState::isAlmostValidMove ( Move  move) const
bool osl::SimpleState::isConsistent ( bool  show_error = true) const
bool osl::state::SimpleState::isEmptyBetween ( Square  from,
Square  to,
Offset  offset,
bool  pieceExistsAtTo = false 
) const
inline
Parameters
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().

bool osl::state::SimpleState::isEmptyBetween ( Square  from,
Square  to,
bool  noSpaceAtTo = false 
) const
inline
Parameters
from- マスの位置
to- マスの位置 fromとtoがクイーンで利きがある位置関係にあるという前提 で,間が全部空白かをチェック

Definition at line 296 of file simpleState.h.

References osl::Board_Table, osl::BoardTable::getShortOffset(), isEmptyBetween(), and osl::Square::isOnBoard().

bool osl::state::SimpleState::isOffBoard ( int  num) const
inline

Definition at line 135 of file simpleState.h.

References osl::BLACK, standMask(), and osl::WHITE.

bool osl::state::SimpleState::isOnBoard ( int  num) const
inline

Definition at line 179 of file simpleState.h.

References osl::Piece::isOnBoard(), and pieceOf().

Referenced by osl::state::NumEffectState::NumEffectState().

bool osl::state::SimpleState::isPawnMaskSet ( Player  player,
int  x 
) const
inline

Definition at line 149 of file simpleState.h.

References pawnMask.

Referenced by canDropPawnTo().

template<Player P>
bool osl::state::SimpleState::isPawnMaskSet ( int  x) const
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().

bool osl::SimpleState::isValidMoveByRule ( Move  move,
bool  show_error 
)
static
template<Player P>
const Piece osl::state::SimpleState::kingPiece ( ) const
inline

Definition at line 86 of file simpleState.h.

References pieceOf().

Referenced by osl::eval::ml::King8Effect::eval().

const Piece osl::state::SimpleState::kingPiece ( Player  P) const
inline

Definition at line 89 of file simpleState.h.

References osl::BLACK, and osl::isValid().

template<Player P>
Square osl::state::SimpleState::kingSquare ( ) const
inline
Square osl::state::SimpleState::kingSquare ( Player  player) const
inline

Definition at line 100 of file simpleState.h.

References osl::BLACK, and osl::isValid().

Piece osl::state::SimpleState::nextPiece ( Square  cur,
Offset  diff 
) const
inline

diff方向にあるPiece を求める.

Returns
盤外ならPTYPE_EDGE

Definition at line 211 of file simpleState.h.

References osl::Piece::EMPTY(), pieceAt(), and osl::Offset::zero().

template<Ptype PTYPE>
const Piece osl::state::SimpleState::nth ( int  n) const
inline

unpromote(PTYPE)のn番目の駒を帰す.

駒番号に依存するので順番は不定.

Definition at line 117 of file simpleState.h.

References pieceOf().

template<Ptype PTYPE>
static int osl::state::SimpleState::nthLimit ( )
inlinestatic

Definition at line 108 of file simpleState.h.

const Piece osl::state::SimpleState::operator[] ( Square  sq) const
inline

Definition at line 171 of file simpleState.h.

References pieceAt().

const Piece osl::state::SimpleState::pieceAt ( Square  sq) const
inline
const Piece osl::state::SimpleState::pieceOf ( int  num) const
inline
const Piece osl::state::SimpleState::pieceOnBoard ( Square  sq) const
inline
const osl::state::SimpleState osl::state::SimpleState::rotate180 ( ) const
void osl::state::SimpleState::setBoard ( Square  sq,
Piece  piece 
)
inline

Definition at line 122 of file simpleState.h.

References board, and osl::Square::index().

void osl::state::SimpleState::setPawn ( Player  pl,
Square  sq 
)
inline

(internal)

Definition at line 145 of file simpleState.h.

References pawnMask.

void osl::SimpleState::setPiece ( Player  player,
Square  sq,
Ptype  ptype 
)
void osl::SimpleState::setPieceAll ( Player  player)
void osl::state::SimpleState::setPieceOf ( int  num,
Piece  p 
)
inline

Definition at line 82 of file simpleState.h.

References pieces.

void osl::state::SimpleState::setTurn ( Player  player)
inline

Definition at line 220 of file simpleState.h.

References player_to_move.

Referenced by flipHorizontal(), and rotate180().

PieceMask& osl::state::SimpleState::standMask ( Player  p)
inlineprotected

Definition at line 127 of file simpleState.h.

References stand_mask.

Referenced by countPiecesOnStandBit(), and isOffBoard().

const PieceMask& osl::state::SimpleState::standMask ( Player  p) const
inline

Definition at line 131 of file simpleState.h.

References stand_mask.

template<bool show_error>
bool osl::state::SimpleState::testValidityOtherThanEffect ( Move  move) const
template<bool show_error>
bool osl::state::SimpleState::testValidityOtherThanEffect ( Move  move) const
protected
Player osl::state::SimpleState::turn ( ) const
inline
const PieceMask& osl::state::SimpleState::usedMask ( ) const
inline

Definition at line 134 of file simpleState.h.

References used_mask.

Referenced by rotate180().

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const SimpleState state 
)
friend
bool operator== ( const SimpleState st1,
const SimpleState st2 
)
friend

盤上の駒のみを比較する(持ち駒は見ない).

なお、駒番に非依存な局面比較をしたい場合は、osl::record::CompactBoardや osl::hash::HashKeyを用いる.

Member Data Documentation

CArray<Piece,Square::SIZE> osl::state::SimpleState::board
protected

Definition at line 50 of file simpleState.h.

Referenced by osl::state::NumEffectState::copyFrom(), getPiecePtr(), pieceAt(), and setBoard().

const bool osl::state::SimpleState::hasPawnMask =true
static

Definition at line 44 of file simpleState.h.

CArray<BitXmask,2> osl::state::SimpleState::pawnMask
protected
CArray<Piece,Piece::SIZE> osl::state::SimpleState::pieces
protected
Player osl::state::SimpleState::player_to_move
protected

手番

Definition at line 64 of file simpleState.h.

Referenced by changeTurn(), osl::state::NumEffectState::copyFrom(), setTurn(), and turn().

CArray<CArray<char,PTYPE_SIZE-PTYPE_BASIC_MIN>,2> osl::state::SimpleState::stand_count
protected

Definition at line 61 of file simpleState.h.

Referenced by osl::state::NumEffectState::copyFrom(), and countPiecesOnStand().

CArray<PieceMask,2> osl::state::SimpleState::stand_mask
protected

Definition at line 59 of file simpleState.h.

Referenced by osl::state::NumEffectState::copyFrom(), and standMask().

PieceMask osl::state::SimpleState::used_mask
protected

Definition at line 65 of file simpleState.h.

Referenced by osl::state::NumEffectState::copyFrom(), and usedMask().


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