10 for (
size_t i = 0; i < weights.
dimension(); ++i)
12 table[i][stage] = weights.
value(i);
22 const int black_count =
24 const int white_count =
26 for (
int j = 0; j < black_count; ++j)
30 for (
int j = 0; j < white_count; ++j)
46 for (
size_t i = 0; i < weights.
dimension(); ++i)
48 table[i][stage] = weights.
value(i);
55 return table[black_count] - table[white_count];
67 for (
int rook = 0; rook <= indices[0]; ++rook)
69 for (
int bishop = 0; bishop <= indices[1]; ++bishop)
71 for (
int gold = 0; gold <= indices[2]; ++gold)
73 for (
int silver = 0; silver <= indices[3]; ++silver)
75 for (
int knight = 0; knight <= indices[4]; ++knight)
77 for (
int lance = 0; lance <= indices[5]; ++lance)
79 if (rook + bishop + gold + silver + knight + lance == 0)
83 result += values[index(rook, bishop,
84 gold, silver, knight, lance)];
98 for (
size_t i = 0; i < ONE_DIM; ++i)
102 orig_table[i][s] = weights.
value(i + ONE_DIM*s);
106 for (indices[0] = 0; indices[0] <= 2; ++indices[0])
108 for (indices[1] = 0; indices[1] <= 2; ++indices[1])
110 for (indices[2] = 0; indices[2] <= 4; ++indices[2])
112 for (indices[3] = 0; indices[3] <= 4; ++indices[3])
114 for (indices[4] = 0; indices[4] <= 4; ++indices[4])
116 for (indices[5] = 0; indices[5] <= 4; ++indices[5])
118 table[index(indices[0],
123 indices[5])] = sumUp(indices, orig_table);
130 table[0] = orig_table[0];
137 for (
size_t i = 0; i < ONE_DIM; ++i)
141 orig_table[i][s] = weights.
value(i + ONE_DIM*s);
145 for (indices[0] = 0; indices[0] <= 2; ++indices[0])
147 for (indices[1] = 0; indices[1] <= 2; ++indices[1])
149 for (indices[2] = 0; indices[2] <= 4; ++indices[2])
151 for (indices[3] = 0; indices[3] <= 4; ++indices[3])
153 for (indices[4] = 0; indices[4] <= 4; ++indices[4])
155 for (indices[5] = 0; indices[5] <= 4; ++indices[5])
191 result = table[black_index] - table[white_index];
192 if (can_check[
WHITE])
194 result += check_table[black_index];
196 if (can_check[
BLACK])
198 result -= check_table[white_index];
212 could_check[0] == can_check[0] && could_check[1] == can_check[1])
216 return eval(state, can_check);
225 for (
size_t i = 0; i < ONE_DIM; ++i)
228 table[i][s] = weights.
value(i + ONE_DIM*s);
242 for (
int j = 0; j < black_count; ++j)
244 const int index_black = index(
BLACK,
BLACK, ptype, j);
245 const int index_white = index(
BLACK,
WHITE, ptype, j);
246 result[
BLACK] += table[index_black];
247 result[
WHITE] += table[index_white];
249 for (
int j = 0; j < white_count; ++j)
251 const int index_black = index(
WHITE,
BLACK, ptype, j);
252 const int index_white = index(
WHITE,
WHITE, ptype, j);
253 result[
BLACK] -= table[index_black];
254 result[
WHITE] -= table[index_white];
259template<osl::Player P>
265 assert(P==moved.
player());
276 const int index_black = index(P,
BLACK, moved.
ptype(), count);
277 const int index_white = index(P,
WHITE, moved.
ptype(), count);
279 result[
BLACK] -= table[index_black];
280 result[
WHITE] -= table[index_white];
283 result[
BLACK] += table[index_black];
284 result[
WHITE] += table[index_white];
292 const int index_black = index(P,
BLACK, ptype, count);
293 const int index_white = index(P,
WHITE, ptype, count);
295 result[
BLACK] += table[index_black];
296 result[
WHITE] += table[index_white];
299 result[
BLACK] -= table[index_black];
300 result[
WHITE] -= table[index_white];
314 for (
size_t i = 0; i < ONE_DIM; ++i)
318 y_attack_table[i][s] = weights.
value(i + ONE_DIM * 2 * s);
319 y_defense_table[i][s] = weights.
value(i + ONE_DIM * 2 * s + ONE_DIM);
322 for (
int i=0;i<7;i++){
325 for(
int king_y=1;king_y<=9;king_y++){
327 for(
int count=0;count<=ptypeSize;count++){
330 int newIndex=(king_y - 1) * 7*19 + i*19 + count;
332 int oldIndex=index(ptype,
BLACK,
Square(5,king_y),count);
333 int newIndex=index(i,
BLACK,
Square(5,king_y),count);
335 y_attack_table_sum[newIndex]=attack_sum;
336 y_defense_table_sum[newIndex]=defense_sum;
337 if(count==ptypeSize)
break;
338 attack_sum += y_attack_table[oldIndex];
339 defense_sum += y_defense_table[oldIndex];
354 result += y_attack_table_sum[attack_index_1] - y_attack_table_sum[attack_index_2] +
355 y_defense_table_sum[defense_index_1] - y_defense_table_sum[defense_index_2];
366 updateResult(state,result,0,
ROOK,kings);
367 updateResult(state,result,1,
BISHOP,kings);
368 updateResult(state,result,2,
GOLD,kings);
369 updateResult(state,result,3,
SILVER,kings);
370 updateResult(state,result,4,
KNIGHT,kings);
371 updateResult(state,result,5,
LANCE,kings);
372 updateResult(state,result,6,
PAWN,kings);
376template<osl::Player P>
391 const int attack_index = index(ptype, P,
394 const int defense_index = index(ptype, P,
398 result -= y_attack_table[attack_index] +y_defense_table[defense_index];
400 result += y_attack_table[attack_index] +y_defense_table[defense_index];
406 const int attack_index = index(ptype, P,
409 const int defense_index = index(ptype, P,
413 result += y_attack_table[attack_index] +y_defense_table[defense_index];
415 result -= y_attack_table[attack_index] +y_defense_table[defense_index];
425 for (
size_t i = 0; i < ONE_DIM; ++i)
427 int low = (i & 0x7F);
431 for (
int s = 0; s <
NStages; ++s)
433 table[i][s] = weights.
value(i + ONE_DIM*s);
436 table[(low << 7) | high][s] = -table[i][s];
461 return table[(black_index << 7) | white_index];
Ptype capturePtype() const
static const CArray< Ptype, 7 > order
持駒の表示で良く使われる順番.
int getIndexLimit(Ptype ptype) const
int getIndexMin(Ptype ptype) const
bool hasPieceOnStand(Player player, Ptype ptype) const
Square kingSquare() const
int countPiecesOnStand(Player pl, Ptype ptype) const
持駒の枚数を数える
static void setUp(const Weights &weights)
static void setUp(const Weights &weights)
static MultiInt sumUp(const CArray< int, 6 > &indices, const CArray< MultiInt, 5625 > &values)
static CArray< MultiInt, 5625 > check_table
static MultiInt eval(const NumEffectState &state, const CArray< bool, 2 > &can_check)
static CArray< MultiInt, 5625 > table
static MultiInt evalWithUpdate(const NumEffectState &state, Move moved, const MultiInt &last_value, const CArray< bool, 2 > &could_check, const CArray< bool, 2 > &can_check)
static int index(int rook, int bishop, int gold, int silver, int knight, int lance)
static void setUp(const Weights &weights)
static CArray< MultiInt, 44 > table
static void evalWithUpdateBang(const NumEffectState &state, Move moved, MultiIntPair &last_value_and_out)
static void eval(const NumEffectState &state, MultiIntPair &out)
static void setUp(const Weights &weights, int stage)
static MultiInt eval(int black_count, int white_count)
static CArray< MultiInt, 21 > table
static MultiInt eval(const NumEffectState &state)
static void setUp(const Weights &weights)
static CArray< MultiInt, 16384 > table
static CArray< MultiInt, 360 > y_attack_table
static int index(Ptype ptype, Player player, Square king, int count)
static CArray< MultiInt, 9 *7 *19 > y_attack_table_sum
static void updateResult(NumEffectState const &state, MultiInt &result, int i, Ptype ptype, CArray< Square, 2 > const &kings)
static MultiInt evalWithUpdate(const NumEffectState &state, Move moved, const MultiInt &last_value)
static MultiInt eval(const NumEffectState &state)
static CArray< MultiInt, 9 *7 *19 > y_defense_table_sum
static CArray< MultiInt, 360 > y_defense_table
static void setUp(const Weights &weights)
static CArray< MultiInt, osl::Piece::SIZE > table
static MultiInt eval(const NumEffectState &state)
static void setUp(const Weights &weights, int stage)
const PtypeTable Ptype_Table
Ptype unpromote(Ptype ptype)
ptypeがpromote後の型の時に,promote前の型を返す. promoteしていない型の時はそのまま返す
constexpr Player alt(Player player)
int value(size_t index) const