11 stand_progresses[
WHITE]=makeProgressStand(
BLACK, state);
12 stand_progresses[
BLACK]=makeProgressStand(
WHITE, state);
21 return makeProgressArea(
alt(defense), state, king)
22 + makeProgressStand(
alt(defense), state);
29 const Square center = Centering5x3::adjustCenter(king);
31 const int min_x = center.
x() - 2;
32 const int min_y = center.
y() - 1;
37 for (
int dx=0; dx<5; ++dx)
39 for (
int dy=0; dy<3; ++dy)
41 const Square target(min_x+dx,min_y+dy);
46 return sum_effect / 2;
83 updateStand(stand_progresses[
alt(pl)], last_move);
87 bool king_move = last_move.
ptype() ==
KING;
89 area_progresses[
WHITE]=makeProgressArea(
BLACK,new_state, kw);
90 if ((king_move && new_state.
turn() ==
WHITE) || mw.anyInRange(Board_Mask_Table5x3_Center.
mask(kb)))
91 area_progresses[
BLACK]=makeProgressArea(
WHITE,new_state, kb);
103 int old = stand_progresses[alt_pl];
122template <osl::Player Defense>
131 const int min_x = center.x() - 2;
132 const int min_y = center.y() - 1;
135 for (
int dx = 0; dx < 5; ++dx)
137 for (
int dy = 0; dy < 3; ++dy)
139 const Square target(min_x+dx, min_y+dy);
197template <osl::Player Attack,
bool AlwaysPromotable,
bool AlwaysNotPromotable>
202 const int min_x = center.
x() - 2;
203 const int min_y = center.
y() - 1;
208 for (
int dy = 0; dy < 3; ++dy)
210 const Square target(king.
x(), min_y + dy);
211 int effect = attackEffect3(state, Attack, target) * 2;
214 if (! AlwaysPromotable
215 && (AlwaysNotPromotable || !target.
canPromote<Attack>()) )
217 effect -= countPawnLanceKnight<Attack>(state, target);
220 sum_effect += effect *
225 for (
int x = king.
x() - 1; x >= min_x; --x)
229 for (
int dy = 0; dy < 3; ++dy)
231 const Square target(x, min_y + dy);
232 int effect = attackEffect3(state, Attack, target) * 2;
235 if (! AlwaysPromotable
236 && (AlwaysNotPromotable || !target.
canPromote<Attack>()) )
238 if (king.
x() - x > 1)
241 effect -= countPawnLanceKnight<Attack>(state, target);
256 for (
int x = king.
x() + 1; x < min_x + 5; ++x)
260 for (
int dy = 0; dy < 3; ++dy)
262 const Square target(x, min_y + dy);
263 int effect = attackEffect3(state, Attack, target) * 2;
266 if (! AlwaysPromotable
267 && (AlwaysNotPromotable || !target.
canPromote<Attack>()) )
269 if (x - king.
x() > 1)
272 effect -= countPawnLanceKnight<Attack>(state, target);
287 return sum_effect / 2;
290template <osl::Player Attack>
297 const bool always_promotable = center.
squareForBlack<Attack>().y() <= 2;
298 if (always_promotable)
299 return makeProgressAreaBonus<Attack,true,false>(state, king, center);
300 const bool always_notpromotable = center.
squareForBlack<Attack>().y() >= 5;
301 if (always_notpromotable)
302 return makeProgressAreaBonus<Attack,false,true>(state, king, center);
303 return makeProgressAreaBonus<Attack,false,false>(state, king, center);
315 const bool update_black = mask.
anyInRange(Board_Mask_Table5x3_Center.
mask(kb));
316 const bool update_white = mask.
anyInRange(Board_Mask_Table5x3_Center.
mask(kw));
320 progress_bonuses[
BLACK]=makeProgressAreaBonus<WHITE>(new_state,kb);
321 effect_mask[
BLACK] = makeEffectMask<BLACK>(new_state);
325 progress_bonuses[
WHITE]=makeProgressAreaBonus<BLACK>(new_state,kw);
326 effect_mask[
WHITE] = makeEffectMask<WHITE>(new_state);
328 updateProgressBonuses(new_state, update_black, update_white);
347 if (update_black && progress_bonuses[
BLACK] != 0)
349 const int pieces = countEffectPieces(state,
WHITE);
350 progress_bonuses[
BLACK] =
351 std::min(pieces * pieces * 4,
352 progress_bonuses[
BLACK]);
354 if (update_white && progress_bonuses[
WHITE] != 0)
356 const int pieces = countEffectPieces(state,
BLACK);
357 progress_bonuses[
WHITE] =
358 std::min(pieces * pieces * 4,
359 progress_bonuses[
WHITE]);
Ptype capturePtype() const
const Square from() const
const NumBitmapEffect effectSetAt(Square sq) const
const BoardMask changedEffects(Player pl) const
int countEffect(Player player, Square target) const
利きの数を数える.
bool hasLongEffectAt(Player P, Square to) const
あるマスにPTYPEの長い利きがあるかどうか.
const PieceMask & piecesOnBoard(Player p) const
bool isOnBoardByOwner() const
piece がプレイヤーPの持ち物でかつボード上にある駒の場合は true.
Square kingSquare() const
int countPiecesOnStand(Player pl, Ptype ptype) const
持駒の枚数を数える
const Piece pieceAt(Square sq) const
int y() const
将棋としてのY座標を返す.
const Square squareForBlack(Player player) const
int x() const
将棋としてのX座標を返す.
const BoardMask & mask(Square p) const
p中心の5x3 の範囲のbitを立てたもの, centering
bool anyInRange(const BoardMask &mask) const
unsigned int piecesOnStand(Ptype ptype) const
持駒のPtypeごとの寄与を表すテーブルの参照.
unsigned int getAttackEffect(Player pl, Square pos, int x, int y) const
Effect5x3Table Effect5x3_Table
Ptype unpromote(Ptype ptype)
ptypeがpromote後の型の時に,promote前の型を返す. promoteしていない型の時はそのまま返す
constexpr int playerToIndex(Player player)
constexpr Player alt(Player player)
PtypeO newPtypeO(Player player, Ptype ptype)
static const Square adjustCenter(Square src)
int countEffectPieces(const NumEffectState &state, Player attack) const
void updateStand(Player pl, Move m)
Effect5x3WithBonus(const NumEffectState &state)
static int attackEffect3(const NumEffectState &state, Player attack, Square target)
Effect5x3WithBonus expect(const NumEffectState &state, Move move) const
static int makeProgressAreaBonus(const NumEffectState &state, Square king)
void updateProgressBonuses(const NumEffectState &state, bool black=true, bool white=true)
static PieceMask makeEffectMask(const NumEffectState &state)
void update(const NumEffectState &new_state, Move last_move)
CArray< PieceMask, 2 > effect_mask
CArray< int, 2 > progress_bonuses
玉の周囲5x3の領域の利きの数と持駒から計算した進行度.
static int makeProgressStand(Player attack, const NumEffectState &state)
CArray< int, 2 > progresses
CArray< int, 2 > stand_progresses
static int makeProgressArea(Player attack, const NumEffectState &state, Square king)
void update(const NumEffectState &new_state, Move last_move)
static void updateStand(int &old_stand, Move last_move)
Effect5x3(const NumEffectState &state)
Effect5x3 expect(const NumEffectState &state, Move move) const
static int makeProgressAll(Player defense, const NumEffectState &state, Square king)