Go to the documentation of this file.
39 if (s ==
"PTYPE_EMPTY")
41 else if (s ==
"PTYPE_EDGE")
43 else if (s ==
"PPAWN")
45 else if (s ==
"PLANCE")
47 else if (s ==
"PKNIGHT")
49 else if (s ==
"PSILVER")
51 else if (s ==
"PBISHOP")
53 else if (s ==
"PROOK")
61 else if (s ==
"LANCE")
63 else if (s ==
"KNIGHT")
65 else if (s ==
"SILVER")
67 else if (s ==
"BISHOP")
72 std::cerr <<
"Incorrect input : " << s << std::endl;
86 return os <<
"PtypeO(" <<
getOwner(ptypeO) <<
","
88 return os <<
"PtypeO(" << (int)ptypeO <<
"," <<
getPtype(ptypeO) <<
")";
98 static const char* names[]={
101 "UUL",
"UUR",
"LONG_UL",
102 "LONG_U",
"LONG_UR",
"LONG_L",
103 "LONG_R",
"LONG_DL",
"LONG_D",
"LONG_DR"
105 return os << names[static_cast<int>(d)];
108 #define OFFSET_INDEX(dx,dy) ((dx*BOARD_HEIGHT + dy) - OFFSET_MIN)
136 std::cerr << index() <<
" " << ZERO().index() <<
"\n";
170 return os <<
"offset(" << offset.
intValue() <<
')';
176 static_assert(
sizeof(
osl::Square) == 4,
"square size");
180 return (1<=x() && x() <=9
181 && 1<=y() && y() <=9);
186 return isPieceStand() || isOnBoard();
211 return os <<
"Square(" << square.
x() << square.
y() <<
")";
214 static_assert(
sizeof(
osl::Piece) == 4,
"piece size");
219 os <<
"Piece(" << piece.
owner() <<
"," << piece.
ptype()
220 <<
",num=" << piece.
number()
221 <<
"," << piece.
square() <<
')';
227 os <<
"unknown piece?!";
233 const int number = ((owner ==
BLACK)
236 return Piece(owner,
KING, number, position);
243 static_assert(
sizeof(
Move) == 4,
"move size");
250 const Square from = this->from();
253 const Square to = this->to();
258 && capturePtype()!=
KING
268 return Move(from().rotate180Safe(), to().rotate180(), ptype(),
269 capturePtype(), isPromotion(),
alt(player()));
275 return os <<
"MOVE_DECLARE_WIN";
277 return os <<
"MOVE_INVALID";
279 return os <<
"MOVE_PASS";
285 os <<
"Drop(" << turn <<
"," << move.
ptype() <<
"," << move.
to() <<
")";
290 os <<
"Move(" << turn <<
"," << move.
ptype() <<
","
291 << move.
from() <<
"->" << move.
to() ;
295 os <<
",capture=" << capture_ptype;
301 os <<
"InvalidMove " << move.
from() <<
" " << move.
to()
323 if((move16&0x80)!=0){
325 return Move(to,ptype,turn);
328 Ptype ptype=state[from].ptype();
329 Ptype capture_ptype=state[to].ptype();
330 bool is_promote=(move16&0x8000)!=0;
334 return Move(from,to,ptype,capture_ptype,
false,turn);
bool isInvalid() const
state に apply 可能でない場合にtrue
bool isOnBoard() const
盤面上を表すかどうかの判定. 1<=x() && x()<=9 && 1<=y() && y()<=9 Squareの内部表現に依存する.
const BoardTable Board_Table
constexpr Player alt(Player player)
int dx() const
Offsetから一般に dxは求まらないので, ここでの入力は12近傍のみとする
Offset32Base< 8, 9 > Offset32
Ptype promote(Ptype ptype)
promote可能なptypeに対して,promote後の型を返す promote不可のptypeを与えてはいけない.
bool isValidPtypeO(int ptypeO)
const Move rotate180() const
Ptype getPtype(PtypeO ptypeO)
static const Piece makeKing(Player owner, Square square)
玉を作る
static const Piece EMPTY()
const char * getName(Ptype ptype) const
Player getOwner(PtypeO ptypeO)
const PtypeTable Ptype_Table
int promoteMask() const
pieceに使うためのmaskなので
std::ostream & operator<<(std::ostream &os, Player player)
static const Move fromMove16(Move16, const SimpleState &)
bool isPieceStand() const
PtypeO oldPtypeO() const
移動前のPtypeO, i.e., 成る手だった場合成る前
bool isOnBoardSlow() const
Ptype capturePtype() const
static const Move DeclareWin()
PtypeO ptypeO() const
移動後のPtype, i.e., 成る手だった場合成った後
const Offset getShortOffsetNotKnight(Offset32 offset32) const
Longの利きの可能性のあるoffsetの場合は, 反復に使う offsetを Knight以外のShortの利きのoffsetの場合はそれ自身を返す.
const Square from() const
bool isValid(Player player)
cast等で作られたplayerが正しいかどうかを返す
int x() const
将棋としてのX座標を返す.
PtypeO
Player + Ptype [-15, 15] PtypeO の O は Owner の O.
const Square back() const
const Offset getOffset(Direction dir) const
const Square nextSquare(Player P, Square pos, Direction dr) const
next position from pos for player P.
constexpr bool isPiece(Ptype ptype)
ptypeが空白やEDGEでないかのチェック
const Square neighbor() const
int y() const
将棋としてのY座標を返す.
static const Move PASS(Player P)
bool isNeighboring8(Square to) const
const Square square() const
static const Piece EDGE()
static Square melt(int index)
#define OFFSET_INDEX(dx, dy)
int dy() const
Offsetから一般に dyは求まらないので, ここでの入力は12近傍のみとする
unsigned int hash() const
駒を取らない手を [0, 16305] にmap
std::istream & operator>>(std::istream &is, Ptype &ptype)
static int compress(Square pos)