Skip to content

Commit

Permalink
- makebook peta_shock_nextで指定した局面数だけ書き出せない時にフリーズしていたのを修正。
Browse files Browse the repository at this point in the history
- makebook peta_shock_nextでrootの指し手を書き出した時にその次の指し手が書き出せずにフリーズしていたのを修正。
- makebook peta_shock_nextでBOOK_VALUE_NONEは考慮しないことにした。
  • Loading branch information
yaneurao committed Jul 23, 2023
1 parent 3996216 commit 0d505e3
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions source/book/makebook2023.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -939,6 +939,8 @@ namespace MakeBook2023
// それぞれのroot_sfenに対して。
for(auto root_sfen : root_sfens)
{
u64 timeup_counter = 0;

// 所定の行数のsfenを書き出すまで回る。
// ただし、局面が尽きることがあるのでrootが存在しなければループは抜ける。
while (true)
Expand All @@ -953,12 +955,19 @@ namespace MakeBook2023
|| hashkey_to_index.count(pos.state()->hash_key()) == 0)
break;

// 書き出す指し手がすべてのrootでなくなっていることを証明するロジックを書くのわりと面倒なので
// timeup_counterをカウントすることにする。
// next_nodesの10倍も回ったらもうあかんやろ…。
if (++timeup_counter > next_nodes * 10)
break;

// PVを辿った時の最後のParentMove
ParentMove last_parent_move(BookNodeIndexNull,0);

// leafの局面までの手順
//string sfen_path = "startpos moves ";


// まずPV leafまで辿る。
while (true)
{
Expand Down Expand Up @@ -995,6 +1004,8 @@ namespace MakeBook2023
// 指し手のなかでbestを選ぶ。同じvalueならdepthが最小であること。
last_parent_move = ParentMove(index,0);

/*
// → BOOK_VALUE_NONE、書き出すのやめることにする。これあまりいいアイデアではなかった。
for(auto& move : moves)
{
if (move.vd.value == BOOK_VALUE_NONE)
Expand All @@ -1012,6 +1023,7 @@ namespace MakeBook2023
move.move = MOVE_NONE;
}
}
*/

ValueDepth parent_vd;
size_t i;
Expand Down Expand Up @@ -1070,8 +1082,9 @@ namespace MakeBook2023
auto& book_node = book_nodes[index];

// 親がいなくなっている = bestmoveを求めても伝播する先かない = このnodeは死んでいる。
if (book_node.parents.size()==0)
continue;
// → ただし、rootの可能性があるので、このノードの処理は行う必要がある。
//if (book_node.parents.size()==0)
// continue;

// 子の局面の指し手がすべてMOVE_NONEなので、子に至るこの指し手を無効化する。
// これでbest_valueに変化が生じるのか?
Expand All @@ -1090,6 +1103,9 @@ namespace MakeBook2023
book_node.moves[move_index].vd = pm.best;
}

if (book_node.parents.size()==0)
continue;

// 親に伝播させる。

if (is_deleted)
Expand Down

0 comments on commit 0d505e3

Please sign in to comment.