1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-04-30 08:43:09 +00:00

盤上から取り除かれた駒に関する差分計算を省き、高速化した

This commit is contained in:
nodchip 2020-06-03 23:32:08 +09:00
parent a85e3055f4
commit 2523f72ff9
3 changed files with 27 additions and 9 deletions

View file

@ -42,7 +42,9 @@ void HalfKP<AssociatedKing>::AppendActiveIndices(
Square sq_target_k;
GetPieces(pos, perspective, &pieces, &sq_target_k);
for (PieceNumber i = PIECE_NUMBER_ZERO; i < PIECE_NUMBER_KING; ++i) {
active->push_back(MakeIndex(sq_target_k, pieces[i]));
if (pieces[i] != Eval::BONA_PIECE_ZERO) {
active->push_back(MakeIndex(sq_target_k, pieces[i]));
}
}
}
@ -59,10 +61,14 @@ void HalfKP<AssociatedKing>::AppendChangedIndices(
if (dp.pieceNo[i] >= PIECE_NUMBER_KING) continue;
const auto old_p = static_cast<BonaPiece>(
dp.changed_piece[i].old_piece.from[perspective]);
removed->push_back(MakeIndex(sq_target_k, old_p));
if (old_p != Eval::BONA_PIECE_ZERO) {
removed->push_back(MakeIndex(sq_target_k, old_p));
}
const auto new_p = static_cast<BonaPiece>(
dp.changed_piece[i].new_piece.from[perspective]);
added->push_back(MakeIndex(sq_target_k, new_p));
if (new_p != Eval::BONA_PIECE_ZERO) {
added->push_back(MakeIndex(sq_target_k, new_p));
}
}
}

View file

@ -50,7 +50,9 @@ void HalfRelativeKP<AssociatedKing>::AppendActiveIndices(
GetPieces(pos, perspective, &pieces, &sq_target_k);
for (PieceNumber i = PIECE_NUMBER_ZERO; i < PIECE_NUMBER_KING; ++i) {
if (pieces[i] >= fe_hand_end) {
active->push_back(MakeIndex(sq_target_k, pieces[i]));
if (pieces[i] != Eval::BONA_PIECE_ZERO) {
active->push_back(MakeIndex(sq_target_k, pieces[i]));
}
}
}
}
@ -69,12 +71,16 @@ void HalfRelativeKP<AssociatedKing>::AppendChangedIndices(
const auto old_p = static_cast<BonaPiece>(
dp.changed_piece[i].old_piece.from[perspective]);
if (old_p >= fe_hand_end) {
removed->push_back(MakeIndex(sq_target_k, old_p));
if (old_p != Eval::BONA_PIECE_ZERO) {
removed->push_back(MakeIndex(sq_target_k, old_p));
}
}
const auto new_p = static_cast<BonaPiece>(
dp.changed_piece[i].new_piece.from[perspective]);
if (new_p >= fe_hand_end) {
added->push_back(MakeIndex(sq_target_k, new_p));
if (new_p != Eval::BONA_PIECE_ZERO) {
added->push_back(MakeIndex(sq_target_k, new_p));
}
}
}
}

View file

@ -21,7 +21,9 @@ void P::AppendActiveIndices(
pos.eval_list()->piece_list_fb() :
pos.eval_list()->piece_list_fw();
for (PieceNumber i = PIECE_NUMBER_ZERO; i < PIECE_NUMBER_KING; ++i) {
active->push_back(pieces[i]);
if (pieces[i] != Eval::BONA_PIECE_ZERO) {
active->push_back(pieces[i]);
}
}
}
@ -32,8 +34,12 @@ void P::AppendChangedIndices(
const auto& dp = pos.state()->dirtyPiece;
for (int i = 0; i < dp.dirty_num; ++i) {
if (dp.pieceNo[i] >= PIECE_NUMBER_KING) continue;
removed->push_back(dp.changed_piece[i].old_piece.from[perspective]);
added->push_back(dp.changed_piece[i].new_piece.from[perspective]);
if (dp.changed_piece[i].old_piece.from[perspective] != Eval::BONA_PIECE_ZERO) {
removed->push_back(dp.changed_piece[i].old_piece.from[perspective]);
}
if (dp.changed_piece[i].new_piece.from[perspective] != Eval::BONA_PIECE_ZERO) {
added->push_back(dp.changed_piece[i].new_piece.from[perspective]);
}
}
}