2 #ifndef PROGRESS_EXPERIMENTAL_NEW_PROGRESS_H 3 #define PROGRESS_EXPERIMENTAL_NEW_PROGRESS_H 24 return (progress >= 0) && (progress < N);
40 return l.
value() < r.value();
70 effect_progresses, defenses;
72 king_relative_attack, king_relative_defense, non_pawn_ptype_attacked_pair;
78 enum { ProgressScale = 2 };
96 template <Player Owner>
97 void updateNonPawnAttackedPtypePairOne(
const NumEffectState& state);
99 template <Player Attack>
105 int &attack,
int &defense);
115 const int x_diff = std::abs(king.
x() - target.
x());
116 const int y_diff = (P ==
BLACK ? king.
y() - target.
y() :
117 target.
y() - king.
y()) + 2;
118 return x_diff * 5 + y_diff;
123 int target_x = (king.
x() > 5 ? 10 - king.
x() : king.
x());
124 int x_diff = king.
x() - target.
x();
125 if (P ==
BLACK && king.
x() >= 6)
129 else if (P ==
WHITE && king.
x() >= 5)
133 const int y_diff = (P ==
BLACK ? king.
y() - target.
y() :
134 target.
y() - king.
y()) + 2;
135 return ((x_diff + 4) * 5 + y_diff) * 5 + target_x - 1;
140 const int x_diff = std::abs(king.
x() - target.
x());
141 const int y_diff = (P ==
BLACK ? king.
y() - target.
y() :
142 target.
y() - king.
y()) + 2;
143 const int king_y = (P ==
BLACK ? king.
y() : 10 - king.
y());
144 return (x_diff * 5 + y_diff) * 9 + king_y - 1;
146 static int index5x5(
int rook,
int bishop,
int gold,
int silver,
149 assert(0 <= promoted && promoted <= 4);
150 return promoted + 5 * (silver + 5 * (gold + 5 * (bishop + 3 * rook)));
152 static int index5x5x(
int rook,
int bishop,
int gold,
int silver,
153 int promoted,
int king_x)
155 assert(0 <= promoted && promoted <= 4);
157 5 * (promoted + 5 * (silver + 5 * (gold + 5 * (bishop + 3 * rook))));
159 static int index5x5y(
int rook,
int bishop,
int gold,
int silver,
160 int promoted,
int king_y)
162 assert(0 <= promoted && promoted <= 4);
164 9 * (promoted + 5 * (silver + 5 * (gold + 5 * (bishop + 3 * rook))));
170 const int x_diff = std::abs(king.
x() - target.
x());
171 const int y_diff = (P ==
BLACK ? king.
y() - target.
y() :
172 target.
y() - king.
y()) + 2;
173 return x_diff * 5 + y_diff +
std::min(8, count) * 25;
180 const int king_y = (P ==
BLACK ? king.
y() : 10 - king.
y());
181 const int x_diff = std::abs(king.
x() - target.
x());
182 const int y_diff = (P ==
BLACK ? king.
y() - target.
y() :
183 target.
y() - king.
y()) + 2;
184 return king_y - 1 + 9 * (x_diff * 5 + y_diff +
std::min(8, count) * 25);
190 const int king_x = (king.
x() > 5 ? 10 - king.
x() : king.
x());
191 int x_diff = king.
x() - target.
x();
192 if ((P ==
BLACK && (king.
x() > 5)) ||
193 (P ==
WHITE && (king.
x() >= 5)))
195 const int y_diff = (P ==
BLACK ? king.
y() - target.
y() :
196 target.
y() - king.
y()) + 2;
197 return king_x - 1 + 5 * (x_diff + 4 +
198 9 * (y_diff + 5 *
std::min(8, count)));
204 const int x = std::abs(pos.
x() - king.
x());
205 const int y = (king.
y() - pos.
y()) *
214 return indexRelative<BLACK>(king, piece.
ptype(),
219 return indexRelative<WHITE>(king, piece.
ptype(),
229 attack5x5_progresses[0] +
230 attack5x5_progresses[1] +
231 stand_progresses[0] + stand_progresses[1] +
232 effect_progresses[0] + effect_progresses[1] +
233 defenses[0] + defenses[1] +
234 king_relative_attack[0] +
235 king_relative_attack[1] +
236 king_relative_defense[0] +
237 king_relative_defense[1] +
238 non_pawn_ptype_attacked_pair[0] +
239 non_pawn_ptype_attacked_pair[1] +
240 pawn_facing + promotion37 + piecestand7,
241 max_progress-ProgressScale), 0) / ProgressScale;
248 updateSub<WHITE>(new_state,last_move);
250 updateSub<BLACK>(new_state,last_move);
263 assert(maxProgress() > 0);
273 non_pawn_ptype_attacked_pair[p],
274 max_progress-ProgressScale), 0)
275 / ProgressScale / maxProgress());
280 assert(maxProgress() > 0);
284 attack5x5_progresses[
alt(p)] +
285 stand_progresses[
alt(p)] +
286 effect_progresses[
alt(p)] +
287 king_relative_attack[
alt(p)],
288 max_progress-ProgressScale), -max_progress+ProgressScale)
289 / ProgressScale / maxProgress() + 8);
294 assert(maxProgress() > 0);
298 king_relative_defense[p] +
299 non_pawn_ptype_attacked_pair[p],
300 max_progress-ProgressScale),
301 -max_progress + ProgressScale)
302 / ProgressScale / maxProgress() + 8);
306 return initialized_flag;
308 static bool setUp(
const char *filename);
310 static std::string defaultFilename();
326 #endif // PROGRESS_EXPERIMENTAL_NEW_PROGRESS_H int max(Player p, int v1, int v2)
static int index(Square king, Square target)
static int index5x5y(int rook, int bishop, int gold, int silver, int promoted, int king_y)
static CArray< int, 56 > piecestand7_weight
static int indexPerEffectY(Square king, Square target, int count)
constexpr Player alt(Player player)
ProgressN< 32 > Progress32
int min(Player p, int v1, int v2)
int y() const
将棋としてのY座標を返す.
CArray< int, 2 > stand_progresses
CArray< int, FEATURE_LIMIT > white_values
bool operator!=(ProgressN< N > l, ProgressN< N > r)
static CArray< int, Piece::SIZE > stand_weight
int x() const
将棋としてのX座標を返す.
static int indexX(Square king, Square target)
static int indexRelative(const Player player, const Square king, const Piece piece)
const Progress16 progressAttack(Player p) const
ProgressN< 16 > Progress16
static int indexPerEffect(Square king, Square target, int count)
MultiInt promotion37_eval
static int index5x5x(int rook, int bishop, int gold, int silver, int promoted, int king_x)
static CArray< int, 4284 > king_relative_weight
CArray< int, FEATURE_LIMIT > black_values
bool operator==(ProgressN< N > l, ProgressN< N > r)
static CArray< int, 75 > effectstate_weight
static bool initialized_flag
void update(const NumEffectState &new_state, Move last_move)
static CArray< int, 81 *15 *10 > defense_relative
constexpr int playerToIndex(Player player)
static int indexRelative(const Square king, const Ptype ptype, const Square pos)
CArray< MultiInt, 2 > non_pawn_ptype_attacked_pair_eval
const Progress16 progress16(Player p) const
const Square square() const
static int index5x5(int rook, int bishop, int gold, int silver, int promoted)
static bool initialized()
const Progress16 progress16() const
static CArray< int, 5625 > attack5x5_x_weight
static CArray< int, 16 > promotion37_weight
static CArray< int, 262144 > attacked_ptype_pair_weight
static CArray< int, 10125 > attack5x5_y_weight
static CArray< int, 81 *15 *10 > attack_relative
const Progress16 progressDefense(Player p) const
static int indexPerEffectX(Square king, Square target, int count)
static int indexY(Square king, Square target)
static CArray< int, 10 > pawn_facing_weight
const NewProgressData rawData() const
static CArray< int, 1125 > attack5x5_weight