65 std::ifstream is(filename);
69 for (
size_t i = 0; i < weights.
dimension(); ++i)
73 effect_weight[i] = val;
76 for (
size_t i = 0; i < 225; ++i)
80 effect_x_weight[i] = val;
83 for (
size_t i = 0; i < 225; ++i)
87 effect_y_weight[i] = val;
91 for (
size_t i = 0; i < weights.
dimension(); ++i)
95 effect_defense_weight[i] = val;
99 for (
size_t i = 0; i < weights.
dimension(); ++i)
103 effect_per_effect[i] = val;
107 for (
size_t i = 0; i < weights.
dimension(); ++i)
111 effect_per_effect_defense[i] = val;
116 for (
size_t i = 0; i < weights.
dimension(); ++i)
120 effect_per_effect_y[i] = val;
124 for (
size_t i = 0; i < weights.
dimension(); ++i)
128 effect_per_effect_x[i] = val;
132 for (
size_t i = 0; i < weights.
dimension(); ++i)
140 for (
size_t i = 0; i < weights.
dimension(); ++i)
148 for (
size_t i = 0; i < weights.
dimension(); ++i)
156 for (
size_t i = 0; i < weights.
dimension(); ++i)
164 for (
size_t i = 0; i < weights.
dimension(); ++i)
172 for (
size_t i = 0; i < weights.
dimension(); ++i)
180 for (
size_t i = 0; i < weights.
dimension(); ++i)
188 for (
size_t i = 0; i < weights.
dimension(); ++i)
196 for (
size_t i = 0; i < weights.
dimension(); ++i)
204 for (
size_t i = 0; i < weights.
dimension(); ++i)
221 for(
int king_x=1;king_x<=9;king_x++){
222 for(
int king_y=1;king_y<=9;king_y++){
223 Square king(king_x,king_y);
224 int king_index=(king_x-1)*9+king_y-1;
226 const int min_x = center.
x() - 2;
227 const int min_y = center.
y() - 1;
229 for (
int dx=0; dx<5; ++dx)
231 for (
int dy=0; dy<3; ++dy,++i)
233 const Square target(min_x+dx,min_y+dy);
234 int index0=king_index*15+i;
235 int index_a=index0*10;
236 int index_d=index0*10;
243 for(
int count=0;count<=8;count++){
255 for(
int king_x=1;king_x<=5;king_x++)
271 for (
int i=2; i<10; ++i)
277 std::cerr <<
"Failed to load NewProgress data " << read_count
278 <<
" from file " << filename << std::endl;
291 filename +=
"/data/progress.txt";
295template <osl::Player P>
301 const int min_x = center.x() - 2;
302 const int min_y = center.y() - 1;
304 attack = defense = 0;
309 int index0=((kingRel.
x()-1)*9+kingRel.
y()-1)*15;
310 int index_a=index0*10 + (P==
WHITE ? 10*14 : 0);
311 for (
int dx=0; dx<5; ++dx)
313 for (
int dy=0; dy<3; ++dy)
315 const Square target(min_x+dx,min_y+dy);
316 const int attack_count =
318 const int defense_count =
335template <osl::Player P>
340 const int min_x = std::max(1, king.
x() - 2);
341 const int max_x = std::min(9, king.
x() + 2);
342 const int min_y = std::max(1, king.
y() - 2);
343 const int max_y = std::min(9, king.
y() + 2);
347 for (
int y = min_y; y <= max_y; ++y)
349 for (
int x = min_x; x <= max_x; ++x)
351 const Square target(x, y);
353 const int effect_diff =
355 const int x_diff = std::abs(x - king.
x());
356 const int y_diff = (P ==
WHITE ? king.
y() - y : y - king.
y());
357 int index = std::max(std::min(effect_diff, 2), -2) + 2 + 5 * x_diff +
358 5 * 3 * (y_diff + 2);
366template <osl::Player P>
377 (mask & ~state.promotedPieces()).selectBit<
SILVER>().countBit();
382 std::min(promoted_pieces.
countBit(), 4);
385template <osl::Player P>
392 king_x = 10 - king_x;
434template <osl::Player Owner>
444 while (attacked.
any())
452 for (
size_t i=0; i<pieces.
size(); ++i) {
453 const int i0 = feature_t::index1(state, pieces[i]);
455 for (
size_t j=i+1; j<pieces.
size(); ++j) {
456 const int i1 = feature_t::index1(state, pieces[j]);
459 result_eval += feature_t::table[feature_t::index2(i0, i1)];
461 result_eval -= feature_t::table[feature_t::index2(i0, i1)];
490template <osl::Player P>
496 for (
int x=1; x<=9; ++x) {
497 const Square target(x, rank);
498 if (! state[target].isEmpty())
535 for (
int z=0; z<2; ++z) {
541 for (
int i=0; i<std::min(7,filled+1); ++i)
566 const int black_count =
568 const int white_count =
570 for (
int j = 0; j < black_count; ++j)
575 for (
int j = 0; j < white_count; ++j)
588template<osl::Player P>
595 assert(new_state.
turn()==altP);
596 assert(last_move.
player()==P);
599 const bool king_move = last_move.
ptype() ==
KING;
640 const int index_attack =
643 const int index_defense =
652 const int index_attack =
654 last_move.
ptype(), last_move.
to());
655 const int index_defense =
657 last_move.
ptype(), last_move.
to()) + 2142;
665 const int index_attack =
668 const int index_defense =
683template<osl::Player P>
689 assert(new_state.
turn()==altP);
694 const bool king_move = last_move.
ptype() ==
KING;
697 if ((king_move && altP ==
BLACK) ||
710 if ((king_move && altP ==
WHITE) ||
void push_back(const T &e)
Ptype capturePtype() const
Ptype oldPtype() const
移動前のPtype, i.e., 成る手だった場合成る前
const Square from() const
const NumBitmapEffect effectSetAt(Square sq) const
const BoardMask changedEffects(Player pl) const
const PieceMask effectedMask(Player pl) const
pl からの利きが(1つ以上)ある駒一覧
int countEffect(Player player, Square target) const
利きの数を数える.
const Piece findCheapAttack(Player P, Square square) const
const PieceMask promotedPieces() const
const PieceMask & piecesOnBoard(Player p) const
bool hasEffectByPtypeStrict(Player attack, Square target) const
target に ptype の利きがあるか?
const mask_t getMask(int num) const
void clearBit()
unpromote(PTYPE) の駒のbit を消す
void orMask(int index, mask_t val)
const mask_t selectBit() const
unpromote(PTYPE) の駒のbit だけ取り出す
static const CArray< Ptype, 7 > order
持駒の表示で良く使われる順番.
const Square square() const
bool hasPieceOnStand(Player player, Ptype ptype) const
const Piece kingPiece() const
const Piece pieceOf(int num) const
Square kingSquare() const
int countPiecesOnStand(Player pl, Ptype ptype) const
持駒の枚数を数える
int y() const
将棋としてのY座標を返す.
const Square rotate180() const
int x() const
将棋としてのX座標を返す.
bool anyInRange(const BoardMask &mask) const
static int index2(int i0, int i1)
int takeOneBit()
non-zeroのmaskのsetされているビットをLSBから探し,その番号を返す 副作用としてmaskの対応するビットをクリアする
void updateMain(const NumEffectState &new_state, Move last_move)
static CArray< int, 5625 > attack5x5_x_weight
static int index5x5x(int rook, int bishop, int gold, int silver, int promoted, int king_x)
static int indexRelative(const Square king, const Ptype ptype, const Square pos)
void updatePawnFacing(const NumEffectState &state)
void promotion37One(const NumEffectState &state, int rank)
void updateAttack5x5PiecesAndState(const NumEffectState &state)
static CArray< int, 75 > effectstate_weight
static void progressOne(const NumEffectState &state, int &attack, int &defense)
static int index5x5y(int rook, int bishop, int gold, int silver, int promoted, int king_y)
void updateSub(const NumEffectState &new_state, Move last_move)
static CArray< int, 16 > promotion37_weight
void updateAttack5x5Pieces(PieceMask, const NumEffectState &)
static CArray< int, 10 > pawn_facing_weight
static int indexPerEffectX(Square king, Square target, int count)
static CArray< int, 81 *15 *10 > defense_relative
NewProgress(const NumEffectState &state)
static std::string defaultFilename()
static int indexY(Square king, Square target)
int attack5x5Value(const NumEffectState &state) const
static bool setUp(const char *filename)
static int indexPerEffectY(Square king, Square target, int count)
void updateNonPawnAttackedPtypePairOne(const NumEffectState &state)
static int indexX(Square king, Square target)
static int index(Square king, Square target)
static CArray< int, 56 > piecestand7_weight
void updatePromotion37(const NumEffectState &state)
static CArray< int, 262144 > attacked_ptype_pair_weight
void updatePieceKingRelativeBonus(const NumEffectState &state)
void updatePieceStand7(const NumEffectState &state)
static int indexPerEffect(Square king, Square target, int count)
static CArray< int, 1125 > attack5x5_weight
static CArray< int, 81 *15 *10 > attack_relative
static CArray< int, Piece::SIZE > stand_weight
void updateNonPawnAttackedPtypePair(const NumEffectState &state)
static bool initialized_flag
static CArray< int, 4284 > king_relative_weight
static CArray< int, 10125 > attack5x5_y_weight
NewProgressDebugInfo debugInfo() const
GeneralMask< mask_int_t > mask_t
bool operator==(const NewProgressData &l, const NewProgressData &r)
const PtypeTable Ptype_Table
constexpr Player indexToPlayer(int n)
const BoardMaskTable5x5 Board_Mask_Table5x5
Ptype unpromote(Ptype ptype)
ptypeがpromote後の型の時に,promote前の型を返す. promoteしていない型の時はそのまま返す
bool isPromoted(Ptype ptype)
ptypeがpromote後の型かどうかのチェック
constexpr int sign(Player player)
constexpr bool isPiece(Ptype ptype)
ptypeが空白やEDGEでないかのチェック
const BoardMaskTable5x3Center Board_Mask_Table5x3_Center
constexpr Player alt(Player player)
PtypeO captured(PtypeO ptypeO)
unpromoteすると共に,ownerを反転する.
static bool hasEffect(const NumEffectState &, Square target, Player attack)
target に attack の追加利きが一つでもあるか. 相手の影利きが先にある場合は対象としない.
static const Square adjustCenter(Square src)
static const std::string & home(const std::string &initialize_if_first_invocation="")
compile時に指定されたディレクトリを返す.
void resetDimension(size_t new_dim)
CArray< int, 2 > effect_progresses
CArray< int, 2 > progresses
CArray< MultiInt, 2 > non_pawn_ptype_attacked_pair_eval
CArray< int, 2 > non_pawn_ptype_attacked_pair
CArray< int, 2 > king_relative_defense
CArray< int, 2 > promoted
CArray< int, 2 > attack5x5_progresses
CArray< int, 2 > king_relative_attack
MultiInt promotion37_eval
CArray< int, 2 > defenses
CArray< int, 2 > stand_progresses
CArray< int, FEATURE_LIMIT > black_values
CArray< int, FEATURE_LIMIT > white_values