Go to the documentation of this file.
3 #ifndef OSL_SIMPLE_STATE_H
4 #define OSL_SIMPLE_STATE_H
26 std::ostream&
operator<<(std::ostream& os,
const SimpleState& state);
32 bool operator==(
const SimpleState& st1,
const SimpleState& st2);
89 return kingPiece<BLACK>();
91 return kingPiece<WHITE>();
95 return kingPiece<P>().
square();
100 return kingSquare<BLACK>();
102 return kingSquare<WHITE>();
104 template <Ptype PTYPE>
113 template <Ptype PTYPE>
115 assert(0 <= n && n < nthLimit<PTYPE>());
157 return hasPieceOnStand<PAWN>(player) && !
isPawnMaskSet(player, x);
187 template <Ptype Type>
210 assert(! diff.
zero());
232 template <
bool show_error>
273 assert(! offset.
zero());
277 if (!pieceExistsAtTo && sq==to)
296 assert(! offset.
zero());
const SimpleState flipHorizontal() const
const Piece pieceAt(Square sq) const
const PieceMask & standMask(Player p) const
bool isOnBoard() const
盤面上を表すかどうかの判定. 1<=x() && x()<=9 && 1<=y() && y()<=9 Squareの内部表現に依存する.
const BoardTable Board_Table
int countPiecesOnStand(Player pl) const
後方互換
constexpr Player alt(Player player)
friend std::ostream & operator<<(std::ostream &os, const SimpleState &state)
Offset32Base< 8, 9 > Offset32
const SimpleState emulateCapture(Piece from, Player new_owner) const
from で表現されたPieceをnew_ownerの持駒にした局面を作る.
static const Piece EMPTY()
PieceMask & standMask(Player p)
mask_t getMaskLow(Ptype ptype) const
void setPiece(Player player, Square sq, Ptype ptype)
int countPiecesOnStandBit(Player pl, Ptype ptype) const
bool isOnBoard(int num) const
void setTurn(Player player)
Square kingSquare(Player player) const
bool isOffBoard(int num) const
Piece nextPiece(Square cur, Offset diff) const
diff方向にあるPiece を求める.
void clearPawn(Player pl, Square sq)
(internal)
const Piece kingPiece(Player P) const
const SimpleState emulateHandPiece(Player from, Player to, Ptype ptype) const
from からto に ptypeの持駒を一枚渡した局面を作る.
const PtypeTable Ptype_Table
const Piece * getPiecePtr(Square sq) const
bool isAlmostValidDrop(Move move) const
std::ostream & operator<<(std::ostream &os, Player player)
const Piece pieceOf(int num) const
bool dump() const
dump: 自分を cerr に表示する。abort 前などにデバッグに使う
const Piece pieceOnBoard(Square sq) const
bool isPawnMaskSet(int x) const
unsigned int index() const
CArray< BitXmask, 2 > pawnMask
const Piece nth(int n) const
unpromote(PTYPE)のn番目の駒を帰す.
bool testValidityOtherThanEffect(Move move) const
friend bool operator==(const SimpleState &st1, const SimpleState &st2)
盤上の駒のみを比較する(持ち駒は見ない).
bool isBasic(Ptype ptype)
ptypeが基本型(promoteしていない)かのチェック
CArray< PieceMask, 2 > stand_mask
void setPawn(Player pl, Square sq)
(internal)
const SimpleState rotate180() const
static const bool hasPawnMask
bool hasPieceOnStand(Player player, Ptype ptype) const
bool isValid(Player player)
cast等で作られたplayerが正しいかどうかを返す
bool isValidMove(Move move, bool show_error=true) const
合法手かどうかを検査する. isValidMoveByRule, isAlmostValidMove をおこなう. 玉の素抜きや王手を防いでいるか, 千日手,打歩詰かどうかは検査しない.
bool isEmptyBetween(Square from, Square to, Offset offset, bool pieceExistsAtTo=false) const
Square kingSquare() const
bool operator==(Square l, Square r)
const Offset getShortOffset(Offset32 offset32) const
Longの利きの可能性のあるoffsetの場合は, 反復に使う offsetを Shortの利きのoffsetの場合はそれ自身を返す.
void setPieceAll(Player player)
static bool isValidMoveByRule(Move move, bool show_error)
盤面以外の部分の反則のチェック
bool isEmptyBetween(Square from, Square to, bool noSpaceAtTo=false) const
bool hasPieceOnStand(Player P) const
const Piece operator[](Square sq) const
CArray< Piece, Piece::SIZE > pieces
全てのpieceが登録されている
const Piece kingPiece() const
const PieceMask & usedMask() const
void setBoard(Square sq, Piece piece)
CArray< CArray< char, PTYPE_SIZE-PTYPE_BASIC_MIN >, 2 > stand_count
CArray< Piece, Square::SIZE > board
void setPieceOf(int num, Piece p)
bool isConsistent(bool show_error=true) const
bool canDropPawnTo(Player player, int x) const
xの筋に歩を打てる
bool isPawnMaskSet(Player player, int x) const
bool isAlmostValidMove(Move move) const
エラー表示をするかどうかをtemplateパラメータにした高速化版
int countPiecesOnStand(Player pl, Ptype ptype) const
持駒の枚数を数える
const PtypeO PTYPEO_EDGE __attribute__((unused))