Skip to content

Commit

Permalink
- ふかうら王、df-pnでmateを見つけた時の処理、GitHubにcommit忘れていた分を反映。
Browse files Browse the repository at this point in the history
  • Loading branch information
yaneurao committed Dec 4, 2024
1 parent 1436a24 commit f25d633
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
7 changes: 6 additions & 1 deletion source/engine/dlshogi-engine/PvMateSearch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,19 @@ namespace dlshogi
// moveの指し手をSetLose()する。
// rootのchildは存在することが保証されている。(Expandしてから探索を開始するので)
auto* child = uct_node->child.get();

for (size_t i = 0; i < uct_node->child_num; ++i)
if (child[i].getMove() == mate_move)
// Node::Moveは上位8bitを使っているので.moveではなく.getMove()を用いる。
{
child[i].SetLose();
return;
break;
}

// 不成の指し手だと⇑で見つからないことがある。
// そのため、rootMateMoveという変数を用意して、こいつに代入することにする。
dl_searcher->rootMateMove = mate_move;

} else {

// SetWinしておけばPV line上なので次のUctSearchで更新されるはず。
Expand Down
9 changes: 5 additions & 4 deletions source/engine/dlshogi-engine/dlshogi_searcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -495,12 +495,13 @@ namespace dlshogi
// 探索スレッドの開始
StartThreads();

// 探索スレッドの終了
TeminateThreads();

// PVの詰み探索スレッド停止
// PVの詰み探索スレッド停止(まず停止命令だけ送っておく)
for (auto& searcher : pv_mate_searchers)
searcher.Stop();

// 探索スレッドの終了(とすべてのスレッドの終了の待機)
TeminateThreads();

// PVの詰み探索スレッド終了待機
for (auto& searcher : pv_mate_searchers)
searcher.Join();
Expand Down
8 changes: 8 additions & 0 deletions source/extra/key128.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,14 @@ struct alignas(16) Key128

Key128 operator + (const Key128& rhs) const { return Key128(*this) += rhs; }
Key128 operator ^ (const Key128& rhs) const { return Key128(*this) ^= rhs; }

// sortなどで使うために比較演算子を定義しておく。
bool operator < (const Key128& rhs) const {
if (this->p[0] != rhs.p[0]) {
return this->p[0] < rhs.p[0];
}
return this->p[1] < rhs.p[1];
}
};

// std::unorded_map<Key128,string>みたいなのを使うときにoperator==とhash化が必要。
Expand Down

0 comments on commit f25d633

Please sign in to comment.