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