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) 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 <<
"unkown 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);
const Move rotate180() const
constexpr Player alt(Player player)
static const Move fromMove16(Move16, const SimpleState &)
static const Piece EDGE()
Ptype getPtype(PtypeO ptypeO)
static const Move PASS(Player P)
int y() const
将棋としてのY座標を返す.
static int compress(Square pos)
std::ostream & operator<<(std::ostream &os, Player player)
static const Piece EMPTY()
PtypeO ptypeO() const
移動後のPtype, i.e., 成る手だった場合成った後
int dy() const
Offsetから一般に dyは求まらないので, ここでの入力は12近傍のみとする
const Offset getShortOffsetNotKnight(Offset32 offset32) const
Longの利きの可能性のあるoffsetの場合は, 反復に使う offsetを Knight以外のShortの利きのoffsetの場合はそ...
int x() const
将棋としてのX座標を返す.
Offset32Base< 8, 9 > Offset32
Ptype promote(Ptype ptype)
promote可能なptypeに対して,promote後の型を返す promote不可のptypeを与えてはいけない. ...
bool isValidPtypeO(int ptypeO)
#define OFFSET_INDEX(dx, dy)
const PtypeTable Ptype_Table
unsigned int index() const
bool isOnBoard() const
盤面上を表すかどうかの判定. 1<=x() && x()<=9 && 1<=y() && y()<=9 Squareの内部表現に依存する. ...
const Square from() const
Player getOwner(PtypeO ptypeO)
bool isOnBoardSlow() const
bool isNeighboring8(Square to) const
bool isValid(Player player)
cast等で作られたplayerが正しいかどうかを返す
const Square neighbor() const
int promoteMask() const
pieceに使うためのmaskなので
static const Piece makeKing(Player owner, Square square)
玉を作る
unsigned int hash() const
駒を取らない手を [0, 16305] にmap
static Square melt(int index)
const Square square() const
Ptype capturePtype() const
PtypeO
Player + Ptype [-15, 15] PtypeO の O は Owner の O.
PtypeO oldPtypeO() const
移動前のPtypeO, i.e., 成る手だった場合成る前
static const Move DeclareWin()
constexpr bool isPiece(Ptype ptype)
ptypeが空白やEDGEでないかのチェック
const Square back() const
const Square nextSquare(Player P, Square pos, Direction dr) const
next position from pos for player P.
const char * getName(Ptype ptype) const
const Offset getOffset(Direction dir) const
int dx() const
Offsetから一般に dxは求まらないので, ここでの入力は12近傍のみとする
bool isPieceStand() const
std::istream & operator>>(std::istream &is, Ptype &ptype)
static const Offset ZERO()
const BoardTable Board_Table
bool isInvalid() const
state に apply 可能でない場合にtrue