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) {
289 const Piece pawn = nth<PAWN>(i);
293 std::cerr <<
"pawn " << pawn << std::endl;
297 for (
int i=0; i<nthLimit<LANCE>(); ++i) {
298 const Piece lance = nth<LANCE>(i);
302 std::cerr <<
"lance " << lance << std::endl;
306 for (
int i=0; i<nthLimit<KNIGHT>(); ++i) {
307 const Piece knight = nth<KNIGHT>(i);
311 std::cerr <<
"knight " << knight << std::endl;
322 const bool valid = isAlmostValidMove<true>(move);
324 std::cerr << *
this <<
" " << move << std::endl;
328 return isAlmostValidMove<false>(move);
331 template <
bool show_error>
340 return isAlmostValidDrop<show_error>(move);
343 if (! testValidityOtherThanEffect<show_error>(move))
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;
380 if (from.isPieceStand())
385 if (show_error) std::cerr <<
" can't drop to : " << move << std::endl;
393 if (show_error) std::cerr <<
" inconsistent promote " << move << std::endl;
405 std::cerr <<
" No such move1 : " << move << std::endl;
415 || from.canPromote(move.
player()))))
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--) {
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;
Ptype unpromote(Ptype ptype)
ptypeがpromote後の型の時に,promote前の型を返す. promoteしていない型の時はそのまま返す ...
bool hasUnblockableEffect() const
短い利きがある.長い利きの隣も含む
CArray< BitXmask, 2 > pawnMask
bool dump() const
dump: 自分を cerr に表示する。abort 前などにデバッグに使う
constexpr Player alt(Player player)
void setPieceAll(Player player)
static const Piece EDGE()
Ptype getPtype(PtypeO ptypeO)
int countPiecesOnStand(Player pl, Ptype ptype) const
持駒の枚数を数える
const SimpleState flipHorizontal() const
void setPiece(Player player, Square sq, Ptype ptype)
const Piece pieceAt(Square sq) const
bool isNormal() const
INVALID でも PASS でもない.
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
unsigned int get(Ptype type) const
int x() const
将棋としてのX座標を返す.
const Offset offset() const
返り値が0なら長い利きがない, 0以外なら辿るのに必要なoffset (2005/3/25 に仕様変更 - 長い利きだが隣の場...
Offset32Base< 8, 9 > Offset32
bool isValidMove(Move move, bool show_error=true) const
合法手かどうかを検査する. isValidMoveByRule, isAlmostValidMove をおこなう. 玉の素抜きや王手を防いで...
const Piece pieceOf(int num) 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 Square from() const
bool hasPieceOnStand(Player player, Ptype ptype) const
bool canDropTo(Player pl, Ptype ptype, Square pos) const
const EffectContent getEffect(PtypeO ptypeo, Square from, Square to) const
fromにいるptypeoがtoに利きを持つか?
CArray< PieceMask, 2 > stand_mask
bool isPromoted() const
promoteした駒かどうかをチェックする
bool isBasic(Ptype ptype)
ptypeが基本型(promoteしていない)かのチェック
bool isOnBoard(int num) const
constexpr int playerToIndex(Player player)
const PieceTable Piece_Table
bool isAlmostValidMove(Move move) const
エラー表示をするかどうかをtemplateパラメータにした高速化版
static const Square nth(unsigned int i)
void setPieceOf(int num, Piece p)
const Square flipHorizontal() const
bool canPromote(Ptype ptype)
ptypeがpromote可能な型かどうかのチェック promote済みの場合はfalseを返す
const Square square() const
PtypeO
Player + Ptype [-15, 15] PtypeO の O は Owner の O.
const PieceMask & usedMask() const
PtypeO oldPtypeO() const
移動前のPtypeO, i.e., 成る手だった場合成る前
bool isPawnMaskSet(Player player, int x) const
bool any() const
どれかの駒を一枚でも持っている
const std::string show(Move)
const SimpleState rotate180() const
void setBoard(Square sq, Piece piece)
bool isPromoted(Ptype ptype)
ptypeがpromote後の型かどうかのチェック
Ptype getPtypeOf(int num) const
static bool validNumber(int num)
static const CArray< Ptype, 7 > order
持駒の表示で良く使われる順番.
static bool isValidMoveByRule(Move move, bool show_error)
盤面以外の部分の反則のチェック
int countPiecesOnStandBit(Player pl, Ptype ptype) const
bool isPromotedNotKingGold() 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が登録されている
bool operator==(Square l, Square r)
const Square squareForBlack(Player player) const
bool isPieceStand() const
const Square rotate180Safe() const
static const Square STAND()
void setTurn(Player player)