はじめに / Overview


usiToCsa.rb is a sample script translating between the CSA and USI protocols, connecting engines speaking the USI protocol to the Shogi-server. It is just a reference implementation, not a recommended or official way to access to the Shogi-server; you can connect with any programs as you like. Note that it has never been tested with the server that is developed by the Computer Shogi Association and used for the World Computer Shogi Championship. It has yet to support Fischer's clock.

ライセンス / License


Same as the Shogi-server (GPL).

動作環境 / Prerequisite

Rubyが必要です。ruby 1.9.3を用いたLinux上での動作を確認しました。Windows上での動作実績はありませんが、修正するにしても比較的軽微な変更で済むと思われます。

Ruby. Tested with ruby 1.9.3 on Linux. Although the author has not tested it on Windows, it would probably work with a little tweaks.

インストール方法 / Install


usiToCsa.rb depends on the Shogi-server's modules, requiring the full set of the Shogi-server. bin/usiToCsa.rb is the main script.

  1. $ git clone
  2. $ cd shogi-server/bin

bin/usiToCsa.rb利用例 / Example

コマンドライン・オプションは、$ usiToCsa.rb --helpをご覧ください。各オプションは、環境変数でも指定できますので、次の2行はどちらも同じ動作です。お好きな方法をお選びください。

You can see various command line options by $ usiToCsa.rb --help. As each option can also be set with environment variables, the following two commands are equivalent.

  1. $ path/to/usiToCsa.rb --id=my_id --password=my_password --gamename=floodgate-900-0 --hash=12000 --ponder=1 --keep-alive=60 ./my_engine
  2. $ env ID=my_id PASSWORD=my_password GAMENAME=floodgate-900-0 HASH=12000 PONDER=1 KEEP_ALIVE=60 path/to/usiToCsa.rb ./my_engine

シェルスクリプト bin/usiToCsa / Sample shell script





A helper shell script drives game matches without human interruption; it attempts to re-login the server soon after the previous game ends.

Your login ID is set by an environment variable ID.

Two ways are available for specifying your password; an environment variable PASSWORD or a file $HOME/.$ID.password.

  1. $ env ID=my_id GAMENAME=floodgate-900-0 HASH=12000 PONDER=1 KEEP_ALIVE=60 path/to/usiToCsa ./my_engine

備考 / Misc

思考時間について / Thinking time management


This script just sends the go command with remaining times. Engines are supposed to control their thinking times and send back best moves autonomously.

ponder(先読み)について / Ponder

ここで解説されているようにgo ponderが思考エンジンに送信されます。そのため、(たとえ対戦相手が大長考したとしても)1手分の候補手しか先読みできません。

As described in here, the script sends engines go ponder, meaning that the engine can only ponder with a single move even if the opponent is thinking for a long period of time.