LoginSignup
0
1

More than 5 years have passed since last update.

コンピュータ将棋ソフトとの対局サーバーを立てよう<その21>

Last updated at Posted at 2017-03-25

前回の記事 : http://qiita.com/muzudho1/items/66cee006062079034fba

bestmove と同時に、info も返すようにしたい。

search.cpp

            if (searcher->signals.stop)
                SYNCCOUT << "info nodes " << searcher->threads.nodesSearched()
                         << " time " << searcher->timeManager.elapsed() << SYNCENDL;
            else if ((pvIdx + 1 == multiPV || searcher->timeManager.elapsed() > 3000)
                     // 将棋所のコンソールが詰まるのを防ぐ。
                     && (rootDepth < 10 * OnePly || lastInfoTime + 200 < searcher->timeManager.elapsed()))
            {
                lastInfoTime = searcher->timeManager.elapsed();
                SYNCCOUT << pvInfoToUSI(rootPos, multiPV, rootDepth, alpha, beta) << SYNCENDL;
            }

マルチPV の1つが終わったタイミングで searcher->signals.stop フラグが true だったら info を出力するみたいなんだが、
bestmove を返す直前に必ず出力するには どうすればいいのか。

探索を止めたいときシグナル・ストップか。
探索を止めたときは いっつも info 返しているのか。
探索ノード数と time しか返してないんじゃないか?

それ以外のときは、3秒以上経過していたら、縛りがあるな。

            if (searcher->signals.stop)
                SYNCCOUT << "info nodes " << searcher->threads.nodesSearched()
                         << " time " << searcher->timeManager.elapsed() << SYNCENDL;
            // (2017-03-25 Modify begin)
            //else if ((pvIdx + 1 == multiPV || searcher->timeManager.elapsed() > 3000)
            //         // 将棋所のコンソールが詰まるのを防ぐ。
            //         && (rootDepth < 10 * OnePly || lastInfoTime + 200 < searcher->timeManager.elapsed()))
            //{
            else if ((pvIdx + 1 == multiPV)
                // 1秒未満で打ち返したい要件と、数ミリ秒経ってからinfoを出す仕組みとは方向性が異なっている。50ms毎に出すか。
                && (rootDepth < 10 * OnePly || lastInfoTime + 50 < searcher->timeManager.elapsed()))
            // (2017-03-25 Modify end)
            {
                lastInfoTime = searcher->timeManager.elapsed();
                SYNCCOUT << pvInfoToUSI(rootPos, multiPV, rootDepth, alpha, beta) << SYNCENDL;
            }

これだと、メッセージ・キューにすぐに出力してしまうが、PHPは 複数メッセージを受け取れるのか? 混線しないか?

それは reservation.php のセマフォで止めてるから大丈夫なのか。

                SERVIO_BEGIN << pvInfoToUSI(rootPos, multiPV, rootDepth, alpha, beta) << SERVIO_END_FLUSH(searcher, "Info");

さらにこんな感じに改造。

どのサーバーでコンパイルするんだ。

g++ が入っていればコンパイルできるか。

# cd /home/★user/sasite1s
# mkdir ukamuse_sdt4_child_tmp
# chmod 777 ukamuse_sdt4_child_tmp

ディレクトリを作ってそこに置くか。

FileZilla で .cpp、.hpp のファイル移動。

# make profgen_sse

時間がかかるので しばらく待つ。

動いている 浮かむ瀬(Sasite1s改造版) を止める。

# ps aux | grep apery
root      1616  0.2 37.6 1613548 382140 pts/0  Sl    3月25   0:13 ./apery --enqueue From_UkamuseSdt4_Sasite1s durable --dequeue To_UkamuseSdt4_Sasite1s durable autodelete
root      3303  0.0  0.1  14264  1060 pts/0    S+   00:02   0:00 grep --color=auto apery
# kill 1616
# mv apery /usr/games/sasite1s/ukamuse_sdt4_sasite1s/bin

再起動。

説明を飛ばして usi ~ position、go。

Enqueue? > 00:21:32 899 34_cs <-------- [interrupt!] Dequeue(^q^) info depth 1 seldepth 1 multipv 1 score cp 63 nodes 64 nps 128 time 498 pv 2g2f

00:21:32 926 34_cs <-------- [interrupt!] Dequeue(^q^) bestmove 2g2f

深さ1 の評価値なんか返しているが、こんなんでいいんだろうか?

現状、1メッセージずつ デキューしてしまう。

info depth 1 seldepth 1 multipv 1 score cp 63 nodes 32 nps 16000 time 2 pv 2g2f #<br />
time = 0.57256197929382
error = "no readyok." info depth 3 seldepth 3 multipv 1 score cp 155 nodes 226 nps 787 time 287 pv 2g2f 3c3d 2f2e
readyok #<br />
time = 0.50812411308289

これでは ちっとも bestmove が出てこないので、改造浮かむ瀬 側で1メッセージにまとめておきたい。

// 入出力を、サービスIOでラッピングします
#define SERVIO_BEGIN_IGNORE service_io::oss_ignore
#define SERVIO_BEGIN_BUFFER service_io::oss_buffer
#define SERVIO_END_IGNORE std::endl, service_io::cleanMessage_Ignore()
#define SERVIO_END_BUFFER(pSearcher,hint) std::endl
#define SERVIO_END_BUFFER_FLUSH(pSearcher,hint) std::endl, service_io::flushMessage_Buffer(pSearcher,hint)

これを使いこなすようにしてみる。

改造浮かむ瀬 を止めて、

# mv apery /usr/games/sasite1s/ukamuse_sdt4_sasite1s/bin/apery
info depth 1 seldepth 1 multipv 1 score cp 63 nodes 32 nps 16000 time 2 pv 2g2f
info depth 2 seldepth 2 multipv 1 score cp 122 nodes 173 nps 714 time 242 pv 7g7f 1c1d
bestmove 2g2f ponder 3c3d

#&lt;br /&gt;<br />
time = 1.4635319709778

info 文字列を入れたら 1.4 秒になった気がするぜ。

50 ミリ間隔で info を出すとダメか。 100 ミリ間隔にしてみるか。

# cd /home/csg11/sasite1s/ukamuse_sdt4_child_tmp
# make profgen_sse
# mv apery /usr/games/sasite1s/ukamuse_sdt4_sasite1s/bin/apery
info depth 1 seldepth 1 multipv 1 score cp 63 nodes 66 nps 33000 time 2 pv 2g2f
info depth 2 seldepth 2 multipv 1 score cp 173 nodes 111 nps 880 time 126 pv 2g2f 1c1d
bestmove 2g2f ponder 1c1d

#&lt;br /&gt;<br />
time = 10.933079004288

こんどは 10秒かかっている。
2回アクセスすると

info depth 1 seldepth 1 multipv 1 score cp 63 nodes 32 nps 16000 time 2 pv 2g2f
info depth 2 seldepth 2 multipv 1 score cp 173 nodes 67 nps 33500 time 2 pv 2g2f 1c1d
info depth 3 seldepth 3 multipv 1 score cp 155 nodes 226 nps 421 time 536 pv 2g2f 3c3d 2f2e
bestmove 2g2f ponder 3c3d

#&lt;br /&gt;<br />
time = 1.9153311252594

今度は 1.9 秒だが。
3回アクセスすると

info depth 1 seldepth 1 multipv 1 score cp 63 nodes 32 nps 16000 time 2 pv 2g2f
info depth 2 seldepth 2 multipv 1 score cp 122 nodes 172 nps 2965 time 58 pv 7g7f 1c1d
info depth 3 seldepth 3 multipv 1 score cp 155 nodes 215 nps 2287 time 94 pv 2g2f 3c3d 2f2e
bestmove 2g2f ponder 3c3d

#&lt;br /&gt;<br />
time = 0.76125979423523

0.7秒。
4回アクセスすると

info depth 1 seldepth 1 multipv 1 score cp 63 nodes 32 nps 16000 time 2 pv 2g2f
info depth 2 seldepth 2 multipv 1 score cp 122 nodes 172 nps 2965 time 58 pv 7g7f 1c1d
info depth 3 seldepth 3 multipv 1 score cp 155 nodes 215 nps 2287 time 94 pv 2g2f 3c3d 2f2e
bestmove 2g2f ponder 3c3d

#&lt;br /&gt;<br />
time = 0.76125979423523

0.76秒。まあまあか。前は0.57秒だったが。

セキュリティ・ソフトが割って入ってきて ブラウザ・アクセスのレスポンスが 遅くなっているのでは?

うーむ。

リポジトリのオーナーを変えたから、ソースツリーの方は、URLを設定しなおす必要があるのでは?

うーむ。

エラーを読むと、プッシュ先のURLが見つかってないみたいだな。

ビットバケツのWebサイトのリポジトリの https のところを見てみると、プッシュ先の https が変わってるな。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1