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