3 #ifndef OSL_BOARD_TABLE_H 4 #define OSL_BOARD_TABLE_H 28 template<Direction Dir>
30 template<Direction Dir>
38 return offsets[
static_cast<int>(dir)];
41 return dxs[
static_cast<int>(dir)];
44 return dys[
static_cast<int>(dir)];
52 return getOffset<BLACK>(dir);
54 return getOffset<WHITE>(dir);
75 Direction ret=directions[blackOffset32.index()];
82 return getLongDirection<BLACK>(offset32);
84 return getLongDirection<WHITE>(offset32);
90 return getLongDirection<P>(
Offset32(to,from));
102 return space_counts[offset32.
index()];
112 return short_offsets[offset32.
index()];
121 return short_offsets_not_knight[offset32.
index()];
142 return getShort8Unsafe<BLACK>(from, to);
144 return getShort8Unsafe<WHITE>(from, to);
149 assert(from.
x()==to.
x() || from.
y()==to.
y() ||
150 abs(from.
x()-to.
x())==abs(from.
y()-to.
y()));
151 return getShort8Unsafe<P>(from,to);
157 assert(from.
x()==to.
x() || from.
y()==to.
y() ||
158 abs(from.
x()-to.
x())==abs(from.
y()-to.
y()));
177 return short8Dir[i1]==short8Dir[i2];
CArray< int, Offset32Wide::SIZE > space_counts
constexpr Direction inverse(Direction d)
Direction getShort8(Square from, Square to, Offset &o) const
const Offset32Base blackOffset32() const
Player P からみた offset を黒番のものに変更する
CArray< signed char, Offset::ONBOARD_OFFSET_SIZE > short8Offset
void setKnightDirections()
bool isBetweenSafe(Square t, Square p0, Square p1) const
int y() const
将棋としてのY座標を返す.
CArray< Direction, Offset32::SIZE > directions
const Offset getShortOffsetNotKnight(Offset32 offset32) const
Longの利きの可能性のあるoffsetの場合は, 反復に使う offsetを Knight以外のShortの利きのoffsetの場合はそ...
int x() const
将棋としてのX座標を返す.
Offset32Base< 8, 9 > Offset32
const Offset getOffsetForBlack(Direction dir) const
黒にとってのoffsetを返す
CArray< Offset, Offset32::SIZE > short_offsets
const Offset getOffset(Player pl, Direction dir) const
bool isOnBoard() const
盤面上を表すかどうかの判定. 1<=x() && x()<=9 && 1<=y() && y()<=9 Squareの内部表現に依存する. ...
static const Offset makeDirect(int value)
bool isValid(Player player)
cast等で作られたplayerが正しいかどうかを返す
bool isBetween(Square t, Square p0, Square p1) const
p0, p1の間にtがあるかどうか.
unsigned int index() const
constexpr int sign(Player player)
CArray< Offset, Offset32::SIZE > short_offsets_not_knight
Direction getLongDirection(Player P, Offset32 offset32) const
static const CArray< int, DIRECTION_SIZE > dxs
int spaceCounts(Square from, Square to) const
fromとtoが長い利きを持つ位置にある時,間のマスの数を求める 一致している時は0 となりも0 関係ない時は-1...
int getDxForBlack(Direction dir) const
Direction getLongDirection(Square from, Square to) const
const Offset getShortOffset(Offset32 offset32) const
Longの利きの可能性のあるoffsetの場合は, 反復に使う offsetを Shortの利きのoffsetの場合はそれ自身を返す...
Offset getShort8OffsetUnsafe(Square from, Square to) const
8方向にいない場合も適当なものを返す.
int getDyForBlack(Direction dir) const
CArray< unsigned char, Offset::ONBOARD_OFFSET_SIZE > short8Dir
const Square nextSquare(Player P, Square pos, Direction dr) const
next position from pos for player P.
Direction getShort8(Square from, Square to) const
Direction getShort8Unsafe(Player P, Square from, Square to) const
Direction getShort8Unsafe(Square from, Square to) const
8方向にいない場合も適当なものを返す.
const Offset getOffset(Direction dir) const
static const CArray< int, DIRECTION_SIZE > dys
Direction getLongDirection(Offset32 offset32) const
unsigned int uintValue() const
static const CArray< Offset, DIRECTION_SIZE > offsets
const BoardTable Board_Table