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