Skip to content

Commit

Permalink
- 電竜戦HWTで持ち時間の使い方が下手すぎたの修正。
Browse files Browse the repository at this point in the history
```
やねうらお — 今日 06:52
■ 電竜戦HWTで持ち時間の使い方が下手すぎる件

残り手数(=MTG)を計算する時、自分手番の残り手数だから、2で割らないといけないのだが、それ割ってなかった。😅
MaxMovesToDrawが256の時はそっちは2で割ってるから(残り)128手でうまく指せていたのだが、MaxMovesToDrawが256の時は256手とMoveToHorizon(=160)のminで160になってて、残り320手に均等に持ち時間配分する感じで指してた。

これだと中盤の難所で時間使わないから弱くなる。

正しくは、このMoveToHorizonも2で割るべきであった。
```
  • Loading branch information
yaneurao committed Jan 16, 2024
1 parent 7a786e0 commit 47e7413
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
22 changes: 12 additions & 10 deletions source/timeman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,19 +110,21 @@ void Timer::init_(const Search::LimitsType& limits, Color us, int ply)
return;
}

// 残り手数
// plyは平手の初期局面が1。
// なので、256手ルールとして、max_game_ply == 256
// 256手目の局面においてply == 256
// その1手前の局面においてply == 255
// これらのときにMTGが1にならないといけない。
// だから2足しておくのが正解。
const int MTG = std::min((limits.max_game_ply - ply + 2) / 2, MoveHorizon);
// 切れ負けであるか?
bool time_forfeit = limits.inc[us] == 0 && limits.byoyomi[us] == 0;

// 切れ負けルールの時は、MoveHorizonを + 40して考える。
const int move_horizon = time_forfeit ? MoveHorizon + 40 : MoveHorizon;

// 残りの自分の手番の回数
// ⇨ plyは平手の初期局面が1。256手ルールとして、max_game_ply == 256だから、256手目の局面においてply == 256
//  その1手前の局面においてply == 255。ply == 255 or 256のときにMTGが1にならないといけない。だから2足しておくのが正解。
const int MTG = std::min(limits.max_game_ply - ply + 2, move_horizon ) / 2;

if (MTG <= 0)
{
// 本来、終局までの最大手数が指定されているわけだから、この条件で呼び出されるはずはないのだが…。
sync_cout << "info string max_game_ply is too small." << sync_endl;
sync_cout << "info string Error! : max_game_ply is too small." << sync_endl;
return;
}
if (MTG == 1)
Expand Down Expand Up @@ -170,7 +172,7 @@ void Timer::init_(const Search::LimitsType& limits, Color us, int ply)


// 切れ負けルールにおいては、5分を切っていたら、このratioを抑制する。
if (limits.inc[us] == 0 && limits.byoyomi[us] == 0)
if (time_forfeit)
{
// 3分 : ratio = 3.0
// 2分 : ratio = 2.0
Expand Down
2 changes: 2 additions & 0 deletions source/usi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,8 @@ void go_cmd(const Position& pos, istringstream& is , StateListPtr& states , bool
int max_game_ply = 0;
if (Options.count("MaxMovesToDraw"))
max_game_ply = (int)Options["MaxMovesToDraw"];

// これ0の時、何らか設定しておかないと探索部でこの手数を超えた時に引き分け扱いにしてしまうので、無限大みたいな定数の設定が必要。
limits.max_game_ply = (max_game_ply == 0) ? 100000 : max_game_ply;

#if defined (USE_ENTERING_KING_WIN)
Expand Down

0 comments on commit 47e7413

Please sign in to comment.