3#ifndef MOBILITY_BISHOP_MOBILITY_H
4#define MOBILITY_BISHOP_MOBILITY_H
51 int count=posDR.
y()-posUL.
y()+
52 posDL.
y()-posUR.
y()-4+
53 (state.
pieceAt(posUR).template canMoveOn<P>() ? 1 : 0)+
54 (state.
pieceAt(posDR).template canMoveOn<P>() ? 1 : 0)+
55 (state.
pieceAt(posUL).template canMoveOn<P>() ? 1 : 0)+
56 (state.
pieceAt(posDL).template canMoveOn<P>() ? 1 : 0);
64 return countAll<P>(state,p.
number());
68 return countAll<BLACK>(state,p);
70 return countAll<WHITE>(state,p);
73 template<Player P, Direction Dir>
78 assert(Dir ==
UL || Dir ==
UR || Dir ==
DL || Dir ==
DR);
81 int count = std::abs(pos.
y() - p.
square().
y())
82 - 1 + (state.
pieceAt(pos).template canMoveOn<P>() ? 1 : 0);
85 template <Direction dir>
88 return countAllDir<BLACK, dir>(state,p);
90 return countAllDir<WHITE, dir>(state,p);
109 return countSafe<BLACK>(state,p);
111 return countSafe<WHITE>(state,p);
Square mobilityOf(Direction d, int num) const
const Square square() const
const Piece pieceAt(Square sq) const
int y() const
将棋としてのY座標を返す.
int countMobilitySafe(Player pl, const NumEffectState &state, Square pos, Offset o)
相手の利きがない動けるマスを求める
constexpr Direction inverse(Direction d)
static int countAllDir(const NumEffectState &state, Piece p)
static int countAllDir(Player pl, const NumEffectState &state, Piece p)
static void countBoth(Player pl, const NumEffectState &state, Piece p, int &countAll, int &countSafe)
static void countBoth(const NumEffectState &state, Piece p, int &countAll, int &countSafe)
斜め方向, P : 駒pの持ち主 countAll : 利きに関係なく動けるマス countSafe : 相手の利きがない動けるマス 両方を求める
static int countAll(Player pl, const NumEffectState &state, Piece p)
static int countSafe(const NumEffectState &state, Piece p)
斜め方向,相手の利きがない動けるマスを求める
static int countAll(const NumEffectState &state, Piece p)
static int countAll(const NumEffectState &state, int num)
斜め方向,利きに関係なく動けるマスの数
static int countSafe(Player pl, const NumEffectState &state, Piece p)