29 num< PtypeTraits<PAWN>::indexLimit; num++){
49 for (
int y=1;y<=9;y++)
50 for (
int x=9;x>0;x--) {
70 std::cerr <<
"unsupported handicap\n";
71 throw std::runtime_error(
"unsupported handicap");
74 for (
int x=9;x>0;x--) {
116 for (num=0;num<40;num++) {
122 Piece p(player,ptype,num,pos);
134 std::cerr <<
"osl::SimpleState::setPiece! maybe too many pieces "
135 << ptype <<
" " << pos <<
" " << player <<
"\n";
140 for (
int num=0;num<40;num++) {
160 for (
int y=1;y<=9;y++)
162 for (
int x=9;x>=1;x--)
171 std::cerr << p0 <<
" must be put at " << pos << std::endl;
177 if (show_error) std::cerr <<
"NotUsed, num=" << num << std::endl;
182 if (show_error) std::cerr <<
"board[" << pos <<
"]!="
183 <<
"piece[" << num <<
"]" << std::endl;
192 if(!
usedMask().test(num0))
continue;
198 if (show_error) std::cerr <<
"ptype of piece[" << num0 <<
"]="
199 << ptype << std::endl;
203 if (show_error) std::cerr <<
"mochigoma[" << num0 <<
"]=true" << std::endl;
208 if (show_error) std::cerr <<
"position " << pos <<
" is not onboard" << std::endl;
214 if (show_error) std::cerr <<
"pieces[" << num0 <<
"]=" << p0 <<
",board[" << pos <<
"] is " << p1 << std::endl;
222#ifdef ALLOW_KING_ABSENCE
228 std::cerr <<
"pieces[" << num0 <<
"] ("
235 if (show_error) std::cerr <<
"ptype of piece[" << num0 <<
"]="
236 << ptype << std::endl;
240 if (show_error) std::cerr << p0 <<
" must be offboard" << std::endl;
249 if (show_error) std::cerr <<
"count stand BLACK " << ptype <<
" inconsistent\n"
256 if (show_error) std::cerr <<
"count stand WHITE " << ptype <<
" inconsistent\n"
265 pawnMask1[0].clearAll();
266 pawnMask1[1].clearAll();
268 num<PtypeTraits<PAWN>::indexLimit;num++){
280 std::cerr <<
"pawnMask "
281 <<
pawnMask[0] <<
"!=" << pawnMask1[0]
282 <<
" || " <<
pawnMask[1] <<
"!=" << pawnMask1[1]
288 for (
int i=0; i<nthLimit<PAWN>(); ++i) {
293 std::cerr <<
"pawn " << pawn << std::endl;
297 for (
int i=0; i<nthLimit<LANCE>(); ++i) {
302 std::cerr <<
"lance " << lance << std::endl;
306 for (
int i=0; i<nthLimit<KNIGHT>(); ++i) {
311 std::cerr <<
"knight " << knight << std::endl;
324 std::cerr << *
this <<
" " << move << std::endl;
331template <
bool show_error>
349 if (!
effect.hasUnblockableEffect())
354 std::cerr <<
" No such move2 : " << move << std::endl;
359 for (
Square p=from+o;p!=to;p+=o) {
362 std::cerr <<
" Not space to move : " << move << std::endl;
385 if (show_error) std::cerr <<
" can't drop to : " << move << std::endl;
393 if (show_error) std::cerr <<
" inconsistent promote " << move << std::endl;
400 if (!
effect.hasUnblockableEffect())
405 std::cerr <<
" No such move1 : " << move << std::endl;
418 std::cerr <<
" illegal promote type or position : " << move << std::endl;
428 std::cerr <<
" must promote to this position : " << move << std::endl;
439 std::cerr <<
"invalid player move : " << move << std::endl;
452 return static_cast<bool>(std::cerr << *
this <<
"\n");
462 for(
int i=0;i<40;i++){
482 assert(from==
alt(to));
485 for(
int i=0;i<40;i++){
508 for (
int i=0; i<40; ++i) {
521 for (
int i=0; i<40; ++i) {
539 for (
int y=1;y<=9;y++)
540 for (
int x=9;x>0;x--) {
553 void showStand(std::ostream& os,
Player player, PieceStand stand)
560 for (
unsigned int j=0; j<stand.get(ptype); ++j)
572 for (
int y=1;y<=9;y++) {
574 for (
int x=9;x>0;x--) {
582 showStand(os,
BLACK, black_stand);
583 showStand(os,
WHITE, white_stand);
585 os << state.
turn() << std::endl;
PtypeO oldPtypeO() const
移動前のPtypeO, i.e., 成る手だった場合成る前
bool isNormal() const
INVALID でも PASS でもない.
const Square from() const
static const CArray< Ptype, 7 > order
持駒の表示で良く使われる順番.
static bool validNumber(int num)
bool isPromoted() const
promoteした駒かどうかをチェックする
const Square square() const
bool isPromotedNotKingGold() const
static const Piece EMPTY()
static const Piece EDGE()
CArray< BitXmask, 2 > pawnMask
const Piece pieceOnBoard(Square sq) const
bool isValidMove(Move move, bool show_error=true) const
合法手かどうかを検査する. isValidMoveByRule, isAlmostValidMove をおこなう. 玉の素抜きや王手を防いでいるか, 千日手,打歩詰かどうかは検査しない.
bool isAlmostValidDrop(Move move) const
bool hasPieceOnStand(Player player, Ptype ptype) const
const SimpleState emulateHandPiece(Player from, Player to, Ptype ptype) const
from からto に ptypeの持駒を一枚渡した局面を作る.
void setTurn(Player player)
const Piece nth(int n) const
unpromote(PTYPE)のn番目の駒を帰す.
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)
bool isOnBoard(int num) const
const SimpleState emulateCapture(Piece from, Player new_owner) const
from で表現されたPieceをnew_ownerの持駒にした局面を作る.
void setPieceAll(Player player)
CArray< PieceMask, 2 > stand_mask
void setBoard(Square sq, Piece piece)
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
int countPiecesOnStandBit(Player pl, Ptype ptype) 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 前などにデバッグに使う
bool isPieceStand() const
int y() const
将棋としてのY座標を返す.
const Square squareForBlack(Player player) const
static const Square STAND()
bool isOnBoard() const
盤面上を表すかどうかの判定. 1<=x() && x()<=9 && 1<=y() && y()<=9 Squareの内部表現に依存する.
int x() const
将棋としてのX座標を返す.
const Square rotate180Safe() const
const Square flipHorizontal() const
static const Square nth(unsigned int i)
const std::string show(Move)
const PtypeTable Ptype_Table
Ptype getPtype(PtypeO ptypeO)
const PieceTable Piece_Table
bool canPromote(Ptype ptype)
ptypeがpromote可能な型かどうかのチェック promote済みの場合はfalseを返す
Ptype unpromote(Ptype ptype)
ptypeがpromote後の型の時に,promote前の型を返す. promoteしていない型の時はそのまま返す
constexpr int playerToIndex(Player player)
bool isPromoted(Ptype ptype)
ptypeがpromote後の型かどうかのチェック
Offset32Base< 8, 9 > Offset32
PtypeO
Player + Ptype [-15, 15] PtypeO の O は Owner の O.
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)