吾輩は猫である 夏目漱石

子供用に。
絵がかわいいね。
原作通り日本語が古いので絵本としてはちょっと読みにくいけど。

Linux(open suse 10.3)でもBonznaははコンパイルできた。

$ gcc --version
gcc (GCC) 4.2.1 (SUSE Linux)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ make -f Makefile gcc
make CC=gcc CFLAGS='-O3 -Wall -DNDEBUG -DMINIMUM -DTLP -DMPV -DCSA_LAN -DNO_LOGGING' LDFLAG1='-lm -lpthread' bonanza
make[1]: ディレクトリ `/home/hoge/bonanza_v4.0.4/src/bonanza' に入ります
gcc -c -O3 -Wall -DNDEBUG -DMINIMUM -DTLP -DMPV -DCSA_LAN -DNO_LOGGING data.c
gcc -c -O3 -Wall -DNDEBUG -DMINIMUM -DTLP -DMPV -DCSA_LAN -DNO_LOGGING main.c
gcc -c -O3 -Wall -DNDEBUG -DMINIMUM -DTLP -DMPV -DCSA_LAN -DNO_LOGGING io.c
gcc -c -O3 -Wall -DNDEBUG -DMINIMUM -DTLP -DMPV -DCSA_LAN -DNO_LOGGING proce.c
gcc -c -O3 -Wall -DNDEBUG -DMINIMUM -DTLP -DMPV -DCSA_LAN -DNO_LOGGING utility.c
gcc -c -O3 -Wall -DNDEBUG -DMINIMUM -DTLP -DMPV -DCSA_LAN -DNO_LOGGING ini.c
gcc -c -O3 -Wall -DNDEBUG -DMINIMUM -DTLP -DMPV -DCSA_LAN -DNO_LOGGING attack.c
gcc -c -O3 -Wall -DNDEBUG -DMINIMUM -DTLP -DMPV -DCSA_LAN -DNO_LOGGING book.c
gcc -c -O3 -Wall -DNDEBUG -DMINIMUM -DTLP -DMPV -DCSA_LAN -DNO_LOGGING makemove.c
gcc -c -O3 -Wall -DNDEBUG -DMINIMUM -DTLP -DMPV -DCSA_LAN -DNO_LOGGING unmake.c
gcc -c -O3 -Wall -DNDEBUG -DMINIMUM -DTLP -DMPV -DCSA_LAN -DNO_LOGGING time.c
gcc -c -O3 -Wall -DNDEBUG -DMINIMUM -DTLP -DMPV -DCSA_LAN -DNO_LOGGING csa.c
gcc -c -O3 -Wall -DNDEBUG -DMINIMUM -DTLP -DMPV -DCSA_LAN -DNO_LOGGING valid.c
gcc -c -O3 -Wall -DNDEBUG -DMINIMUM -DTLP -DMPV -DCSA_LAN -DNO_LOGGING bitop.c
gcc -c -O3 -Wall -DNDEBUG -DMINIMUM -DTLP -DMPV -DCSA_LAN -DNO_LOGGING iterate.c
gcc -c -O3 -Wall -DNDEBUG -DMINIMUM -DTLP -DMPV -DCSA_LAN -DNO_LOGGING searchr.c
gcc -c -O3 -Wall -DNDEBUG -DMINIMUM -DTLP -DMPV -DCSA_LAN -DNO_LOGGING search.c
gcc -c -O3 -Wall -DNDEBUG -DMINIMUM -DTLP -DMPV -DCSA_LAN -DNO_LOGGING quiesrch.c
gcc -c -O3 -Wall -DNDEBUG -DMINIMUM -DTLP -DMPV -DCSA_LAN -DNO_LOGGING evaluate.c
gcc -c -O3 -Wall -DNDEBUG -DMINIMUM -DTLP -DMPV -DCSA_LAN -DNO_LOGGING swap.c
gcc -c -O3 -Wall -DNDEBUG -DMINIMUM -DTLP -DMPV -DCSA_LAN -DNO_LOGGING hash.c
gcc -c -O3 -Wall -DNDEBUG -DMINIMUM -DTLP -DMPV -DCSA_LAN -DNO_LOGGING root.c
gcc -c -O3 -Wall -DNDEBUG -DMINIMUM -DTLP -DMPV -DCSA_LAN -DNO_LOGGING next.c
gcc -c -O3 -Wall -DNDEBUG -DMINIMUM -DTLP -DMPV -DCSA_LAN -DNO_LOGGING movgenex.c
gcc -c -O3 -Wall -DNDEBUG -DMINIMUM -DTLP -DMPV -DCSA_LAN -DNO_LOGGING genevasn.c
gcc -c -O3 -Wall -DNDEBUG -DMINIMUM -DTLP -DMPV -DCSA_LAN -DNO_LOGGING gencap.c
gcc -c -O3 -Wall -DNDEBUG -DMINIMUM -DTLP -DMPV -DCSA_LAN -DNO_LOGGING gennocap.c
gcc -c -O3 -Wall -DNDEBUG -DMINIMUM -DTLP -DMPV -DCSA_LAN -DNO_LOGGING gendrop.c
gcc -c -O3 -Wall -DNDEBUG -DMINIMUM -DTLP -DMPV -DCSA_LAN -DNO_LOGGING mate1ply.c
gcc -c -O3 -Wall -DNDEBUG -DMINIMUM -DTLP -DMPV -DCSA_LAN -DNO_LOGGING rand.c
gcc -c -O3 -Wall -DNDEBUG -DMINIMUM -DTLP -DMPV -DCSA_LAN -DNO_LOGGING learn1.c
gcc -c -O3 -Wall -DNDEBUG -DMINIMUM -DTLP -DMPV -DCSA_LAN -DNO_LOGGING learn2.c
gcc -c -O3 -Wall -DNDEBUG -DMINIMUM -DTLP -DMPV -DCSA_LAN -DNO_LOGGING evaldiff.c
gcc -c -O3 -Wall -DNDEBUG -DMINIMUM -DTLP -DMPV -DCSA_LAN -DNO_LOGGING problem.c
gcc -c -O3 -Wall -DNDEBUG -DMINIMUM -DTLP -DMPV -DCSA_LAN -DNO_LOGGING ponder.c
gcc -c -O3 -Wall -DNDEBUG -DMINIMUM -DTLP -DMPV -DCSA_LAN -DNO_LOGGING thread.c
gcc -c -O3 -Wall -DNDEBUG -DMINIMUM -DTLP -DMPV -DCSA_LAN -DNO_LOGGING sckt.c
gcc -c -O3 -Wall -DNDEBUG -DMINIMUM -DTLP -DMPV -DCSA_LAN -DNO_LOGGING debug.c
gcc -c -O3 -Wall -DNDEBUG -DMINIMUM -DTLP -DMPV -DCSA_LAN -DNO_LOGGING mate3.c
gcc -c -O3 -Wall -DNDEBUG -DMINIMUM -DTLP -DMPV -DCSA_LAN -DNO_LOGGING genchk.c
gcc -lm -lpthread -o bonanza data.o main.o io.o proce.o utility.o ini.o attack.o book.o makemove.o unmake.o time.o csa.o valid.o bitop.o iterate.o searchr.o search.o quiesrch.o evaluate.o swap.o hash.o root.o next.o movgenex.o genevasn.o gencap.o gennocap.o gendrop.o mate1ply.o rand.o learn1.o learn2.o evaldiff.o problem.o ponder.o thread.o sckt.o debug.o mate3.o genchk.o
make[1]: ディレクトリ `/home/hoge/bonanza_v4.0.4/src/bonanza' から出ます

Bonanza Version 4.0.4 はCygwinでもコンパイル可能

でした。
特に困ることはありません。

$ gcc --version
gcc (GCC) 3.4.4 (cygming special, gdc 0.12, using dmd 0.125)
Copyright (C) 2004 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ make --version
GNU Make 3.81
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.

This program built for i686-pc-cygwin

$ make -f Makefile gcc
make CC=gcc CFLAGS='-O3 -Wall -DNDEBUG -DMINIMUM -DTLP -DMPV -DCSA_LAN -DNO_LOGGING' LDFLAG1='-lm -lpthread' bonanza
make[1]: Entering directory `/home/hoge/bonanza_v4.0.4/src/bonanza'
gcc -c -O3 -Wall -DNDEBUG -DMINIMUM -DTLP -DMPV -DCSA_LAN -DNO_LOGGING data.c
gcc -c -O3 -Wall -DNDEBUG -DMINIMUM -DTLP -DMPV -DCSA_LAN -DNO_LOGGING main.c
gcc -c -O3 -Wall -DNDEBUG -DMINIMUM -DTLP -DMPV -DCSA_LAN -DNO_LOGGING io.c
gcc -c -O3 -Wall -DNDEBUG -DMINIMUM -DTLP -DMPV -DCSA_LAN -DNO_LOGGING proce.c
gcc -c -O3 -Wall -DNDEBUG -DMINIMUM -DTLP -DMPV -DCSA_LAN -DNO_LOGGING utility.c
gcc -c -O3 -Wall -DNDEBUG -DMINIMUM -DTLP -DMPV -DCSA_LAN -DNO_LOGGING ini.c
gcc -c -O3 -Wall -DNDEBUG -DMINIMUM -DTLP -DMPV -DCSA_LAN -DNO_LOGGING attack.c
gcc -c -O3 -Wall -DNDEBUG -DMINIMUM -DTLP -DMPV -DCSA_LAN -DNO_LOGGING book.c
gcc -c -O3 -Wall -DNDEBUG -DMINIMUM -DTLP -DMPV -DCSA_LAN -DNO_LOGGING makemove.c
gcc -c -O3 -Wall -DNDEBUG -DMINIMUM -DTLP -DMPV -DCSA_LAN -DNO_LOGGING unmake.c
gcc -c -O3 -Wall -DNDEBUG -DMINIMUM -DTLP -DMPV -DCSA_LAN -DNO_LOGGING time.c
gcc -c -O3 -Wall -DNDEBUG -DMINIMUM -DTLP -DMPV -DCSA_LAN -DNO_LOGGING csa.c
gcc -c -O3 -Wall -DNDEBUG -DMINIMUM -DTLP -DMPV -DCSA_LAN -DNO_LOGGING valid.c
gcc -c -O3 -Wall -DNDEBUG -DMINIMUM -DTLP -DMPV -DCSA_LAN -DNO_LOGGING bitop.c
gcc -c -O3 -Wall -DNDEBUG -DMINIMUM -DTLP -DMPV -DCSA_LAN -DNO_LOGGING iterate.c
gcc -c -O3 -Wall -DNDEBUG -DMINIMUM -DTLP -DMPV -DCSA_LAN -DNO_LOGGING searchr.c
gcc -c -O3 -Wall -DNDEBUG -DMINIMUM -DTLP -DMPV -DCSA_LAN -DNO_LOGGING search.c
gcc -c -O3 -Wall -DNDEBUG -DMINIMUM -DTLP -DMPV -DCSA_LAN -DNO_LOGGING quiesrch.c
gcc -c -O3 -Wall -DNDEBUG -DMINIMUM -DTLP -DMPV -DCSA_LAN -DNO_LOGGING evaluate.c
gcc -c -O3 -Wall -DNDEBUG -DMINIMUM -DTLP -DMPV -DCSA_LAN -DNO_LOGGING swap.c
gcc -c -O3 -Wall -DNDEBUG -DMINIMUM -DTLP -DMPV -DCSA_LAN -DNO_LOGGING hash.c
gcc -c -O3 -Wall -DNDEBUG -DMINIMUM -DTLP -DMPV -DCSA_LAN -DNO_LOGGING root.c
gcc -c -O3 -Wall -DNDEBUG -DMINIMUM -DTLP -DMPV -DCSA_LAN -DNO_LOGGING next.c
gcc -c -O3 -Wall -DNDEBUG -DMINIMUM -DTLP -DMPV -DCSA_LAN -DNO_LOGGING movgenex.c
gcc -c -O3 -Wall -DNDEBUG -DMINIMUM -DTLP -DMPV -DCSA_LAN -DNO_LOGGING genevasn.c
gcc -c -O3 -Wall -DNDEBUG -DMINIMUM -DTLP -DMPV -DCSA_LAN -DNO_LOGGING gencap.c
gcc -c -O3 -Wall -DNDEBUG -DMINIMUM -DTLP -DMPV -DCSA_LAN -DNO_LOGGING gennocap.c
gcc -c -O3 -Wall -DNDEBUG -DMINIMUM -DTLP -DMPV -DCSA_LAN -DNO_LOGGING gendrop.c
gcc -c -O3 -Wall -DNDEBUG -DMINIMUM -DTLP -DMPV -DCSA_LAN -DNO_LOGGING mate1ply.c
gcc -c -O3 -Wall -DNDEBUG -DMINIMUM -DTLP -DMPV -DCSA_LAN -DNO_LOGGING rand.c
gcc -c -O3 -Wall -DNDEBUG -DMINIMUM -DTLP -DMPV -DCSA_LAN -DNO_LOGGING learn1.c
gcc -c -O3 -Wall -DNDEBUG -DMINIMUM -DTLP -DMPV -DCSA_LAN -DNO_LOGGING learn2.c
gcc -c -O3 -Wall -DNDEBUG -DMINIMUM -DTLP -DMPV -DCSA_LAN -DNO_LOGGING evaldiff.c
gcc -c -O3 -Wall -DNDEBUG -DMINIMUM -DTLP -DMPV -DCSA_LAN -DNO_LOGGING problem.c
gcc -c -O3 -Wall -DNDEBUG -DMINIMUM -DTLP -DMPV -DCSA_LAN -DNO_LOGGING ponder.c
gcc -c -O3 -Wall -DNDEBUG -DMINIMUM -DTLP -DMPV -DCSA_LAN -DNO_LOGGING thread.c
gcc -c -O3 -Wall -DNDEBUG -DMINIMUM -DTLP -DMPV -DCSA_LAN -DNO_LOGGING sckt.c
gcc -c -O3 -Wall -DNDEBUG -DMINIMUM -DTLP -DMPV -DCSA_LAN -DNO_LOGGING debug.c
gcc -c -O3 -Wall -DNDEBUG -DMINIMUM -DTLP -DMPV -DCSA_LAN -DNO_LOGGING mate3.c
gcc -c -O3 -Wall -DNDEBUG -DMINIMUM -DTLP -DMPV -DCSA_LAN -DNO_LOGGING genchk.c
gcc -lm -lpthread -o bonanza data.o main.o io.o proce.o utility.o ini.o attack.o book.o makemove.o unmake.o time.o csa.o valid.o bitop.o iterate.o searchr.o search.o quiesrch.o evaluate.o swap.o hash.o root.o next.o movgenex.o genevasn.o gencap.o gennocap.o gendrop.o mate1ply.o rand.o learn1.o learn2.o evaldiff.o problem.o ponder.o thread.o sckt.o debug.o mate3.o genchk.o
make[1]: Leaving directory `/home/hoge/bonanza_v4.0.4/src/bonanza'

$ mv ../../winbin/*.bin .

$ ./bonanza
Bonanza Version 4.0.4 - The Computer Shogi Program
Trans. Table Entries = 768K (12MB)
cleanning the transposition table ... done ( 0.04s)
book.bin found
hash.bin found
rand seed = 53967104
Black 1>

Bonanza Version 4.0.4 bonanza_v4.0.3\src\bonanza\bonanza.txt 翻訳

少しずつ訳していきます。
正確ではないです。

                                                                                                                                          • -

Bonanza Version 4.0.4 Source Code
Kunihito Hoki, 2 Feb 2009

                                                                                                                                          • -


1. Introduction

                              • -

Bonanza is a state-of-the art computer shogi engine which runs on
Windows and Linux machines, and this directory contains a
platform-independent source code.

ボナンザは最先端のコンピューター将棋エンジンでWindowsLinuxそれぞれのプラットフォームで動きます。しかもソースコード付き!
このソースコードはコンピュータ将棋エンジンのパーツとして役に立つという望みを持って配布されます。

This source code is distributed with a hope that it will be useful in
addition to the main part of the shogi engine. This program includes
many useful functions such as manipulating a shogi board, reading and
writing a CSA record file, speaking of a CSA protocol with a socket
communication, and controlling time, and etc.. I believe this program
can be a good starting point if you are interested in making shogi
programs.

このプログラムは多くの有用な関数、将棋盤を操作したり、CSAファイルを読んだり書いたり、CSAのプロトコルで操作、時間制御・・・などなど含みます。私はこのプログラムがコンピューター将棋を作るよいスタート地点になることを信じています。

One main feature of this program is that it employs a brute-force
search method together with bitboard techniques as many chess programs
do. Another notable feature is a machine learning of shogi evaluation
functions. The details of the learning algorithm (aka Bonanza method)
were already presented [1], and this source code provides an example
of implementation of the learning method.

このプログラムのひとつの大きな特徴としてチェスのそれに用いられるビットボード技術を用いた総当たり探索があります。そのほかの特徴として機械学習関数があります。その学習アルゴリズムはすでに公開されており、さらにこのソースコードでも学習メソッドの実装の例を提供しています。

I admit that some parts of the source code are cryptic, e.g. codes in
"mate1ply.c". I hope that I will have some time to make a quality
documentation and comments on the program code, or someone else could
decrypt my program and provide a documentation.

私は、ソースコードのいくつかの部分が不可解であることを認めます。たとえば”mate1ply.c”。私にはプログラム・コードの品質文書とコメントをするいくらかの時間があるこ
とを願っているか、他の誰かが、私のプログラムを解読して、ドキュメンテーションを提供するかもしれません。

Any comments or suggestions are welcome [2].

どんなコメントや提案も歓迎します。

[1] K. Hoki, "Optimal control of minimax search results to learn
positional evaluation", Game Programing Workshop, Hakone, Japan
2008.

[2] Contact to "bonanza_query [at] hotmail.com".


2. Legal Notices

                                • -

This program is protected by copyright. Without a specific
permission, any means of commercial applications are prohibited.
Furthermore, this program is distributed without a warrantee.
Within these limits, you can use, redistribute, and/or modify it.

法律云々について

このプログラムは著作権によって保護されます。 特別に許可がなければ、アプリケーションとして売ることはできません。
また、このプログラムは被保証人なしで配布されます。
これらの制約の中でなら使用し、再配付、そして変更することができます。


3. Change Logs

                    • -

Version 4.0.4 (2 Feb 2009)

  • An error of GCC inline assembly for spinlock in "thread.c" is fixed.
  • In Windows OS, Bonanza now opens all streams with file sharing by

using "_SH_DENYNO" constant in "io.c".

  • GCC built-in functions are substituted for GCC inline assemblies for

bit-scan operations in "bitop.h". Furthermore, "bitop.h" is removed,
and some of macros in the header are integrated into "shogi.h".

GCCでスピンロックするエラーがあったのでthread.cを修正しました。
Windows OSでは、Bonanzaはファイル共有でSH_DENYNOを使用することによって、すべてのストリームを開きます。"io.c"では一定です。
・"bitop.h"でのビット・スキャン操作のためのGCCインラインアセンブリGCC
込み関数を代入します。 その上、"bitop.h"は移されます。そしてヘッダーのマクロのいくつかが"shogi.h"と統合されます。

Version 4.0.3 (Jan 2008)


4. Files

                • -

Here is a list of files you can find in this directory.

ここにあなたがこのディレクトリで見つけることができるファイルのリストがあります。

C headers

  • param.h piece values
  • shogi.h main header

C ヘッダーファイル

  • param.h 駒の価値
  • shogi.h メインヘッダー

basic C functions

  • main.c main function of C program
  • data.c definition of global variables
  • ini.c initializations
  • rand.c pseudo random number generator
  • time.c time functions
  • bitop.c bit operation
  • utility.c misc. functions

basic C functions

  • main.c C言語のメイン・・・mainです
  • data.c グローバル変数が定義されている
  • ini.c 初期設定
  • rand.c 疑似乱数ジェネレータ
  • time.c 時間関数
  • bitop.c ビット操作
  • utility.c ユーティリティ関数群

I/O

  • proce.c input procedure
  • csa.c csa file format I/O
  • io.c basic I/O
  • dek.c dekunobou
  • sckt.c TCP/IP client of CSA SHOGI protocol

I/O

  • proce.c インプット
  • csa.c csaのファイルフォーマットI/O
  • io.c ベーシック I/O
  • dek.c デクノボウ?
  • sckt.c CSAプロトコルTCP/IPクライアント

bitboard manipulations

  • attack.c piece attacks
  • genchk.c move generation (checks)
  • genevasn.c move generation (evasions)
  • gendrop.c move generation (drops)
  • gennocap.c move generation (non-captures)
  • gencap.c move generation (captures)
  • movgenex.c move generation (inferior moves)
  • makemove.c make moves
  • unmake.c unmake move
  • mate1ply.c 1-ply mate detection
  • debug.c examine bitboard validity

ビットボード 操作

  • attack.c 駒の利き
  • genchk.c 王手の生成
  • genevasn.c 王手回避の生成
  • gendrop.c 駒を打つ手生成
  • gennocap.c 駒を取らない手生成
  • gencap.c 駒を取る手生成
  • movgenex.c 下向きの動き生成
  • makemove.c 成り
  • unmake.c 成らず
  • mate1ply.c 1手詰め発見
  • debug.c ビットボードが正しいか調べる

brute-force search

  • iterate.c iterative deepning search at root node
  • searchr.c alpha-beta search at root node
  • search.c alpha-beta search
  • next.c obtains next move
  • quiesrch.c quiescence search
  • evaluate.c static eveluation function
  • evaldiff.c easy and fast evaluation function
  • swap.c static exchange evaluation
  • hash.c transposition table
  • thread.c thread-level parallelization
  • root.c root move genelation and shallow min-max search
  • mate3.c 3-ply mate detection
  • ponder.c pondering
  • book.c creates and probes opening book
  • problem.c auto problem solver
  • valid.c examine move validity

総当たり探索

  • iterate.c 反復探索(ルートノード)
  • searchr.c αβ探索(ルートノード)
  • search.c αβ探索
  • next.c 次に移るところをゲット
  • quiesrch.c 静的探索
  • evaluate.c 静的評価関数
  • evaldiff.c 簡単かつ高速な評価関数
  • swap.c SEE
  • hash.c ハッシュ化テーブル
  • thread.c スレッド並列化
  • root.c 根移動生成、浅い min-max探索
  • mate3.c 3手詰め発見
  • ponder.c 熟考
  • book.c 定石ファイルの使用
  • problem.c 自動問題解決
  • valid.c 合法手調査

optimal control of min-max search

  • learn1.c main functions
  • learn2.c feture vector manipuration

min-max 探索の最適化

  • learn1.c メイン関数
  • learn2.c ベクトル操作

misc.

その他

4. How to build Bonanza

                                            • -

You can build Bonanza by means of GNU Make on Linux or Microsoft NMAKE
on Windows. Here is some examples:

ボナンザはLinuxGNU Make でも WindowsのNMAKEでもビルドできます。下記が例です。

補足)bonanza_v4.0.3\src\bonanza\をカレントディレクトリとして下記を実行する必要がある。

> make -f Makefile gcc

> make -f Makefile icc

> nmake -f Makefile.vs cl

> nmake -f Makefile.vs icl

The C source codes are written by using ANSI C plus a small number of
new features in ISO C99. Therefore, I think this can be easily built
in many platforms without much effort.

これらC言語ソースコードANSI C ISO C99で書かれています。
従って多くのプラットフォームで苦労することなく容易にビルドできるでしょう。

It may be necessary to define some macros in Makefile or
Makefile.vs. The macros are:

いくつかのマクロをMakefileMakefile.vsで定義する必要があると思います。
そのマクロは・・・

  • NDEBUG (DEBUG) builds release (debug) version of Bonanza

ボナンザのリリースバージョン

  • MINIMUM disables some auxiliary functions that are not

necessary to play a game, e.g., book composition
and optimization of evaluation functions

  • TLP enables thread-level parallel search
  • MPV enables multi-PV search

protcol

  • DEKUNOBOU enables dekunobou interface (available only for

Windows)

  • CSASHOGI builds an engine for CSA Shogi (available only for

Windows)

  • NO_LOGGING suppresses dumping log files

Bonanza is an application that does not provide graphical user
interface. If you could build "bonanza.exe" properly without CSASHOGI
macro, it shows a prompt "Black 1>" when you execute it at a computer
console.

Bonanza uses three binary files: a feature vector of static evaluation
function "fv.bin", an opening book "book.bin", and a
position-learning database "hash.bin". You can find these in "winbin/"
directory. Without the NO_LOGGING option, Bonanza must find "log/"
directory to dump log files.


5. Command List

                            • -

These commands enable (on) or disable (off) a beep when Bonanza
makes a move. The default is on.

  • book on
  • book off

These commands enable (on) or disable (off) to probe the opening
book, "./book.bin". The default is on.

  • book narrow
  • book wide

When the command with "narrow" is used, Bonanza selects a book
move from a small set of opening moves. The default is "wide". The
narrowing of the opening moves is useful if you want Bonanza
choose a common opening line.

  • book create

This command creates the opening book file, "./book.bin", by using
numerous experts' games in a single CSA record file, "./book.csa".
It also uses another CSA record file, "book_anti.csa", where you
can register bad moves that may appear in the experts' games at
the last moves in the record file. Here is the example:

                                                                              • -

PI, +, +6978KI, %TORYO
/
PI, +, +6978KI, -8384FU, %TORYO
/
PI, +, +7776FU, -4132KI, %TORYO
/
PI, +, +7776FU, -4132KI, +2726FU, %TORYO

                                                                              • -

This command becomes effective when MINIMUM macro is not defined
in the Makefile.

  • connect 'addr' 'port' 'id' 'passwd' ['ngame']

This command connects Bonanza to a shogi server by using the CSA
protocol. The first four arguments specify the network address,
port number, user ID, and password, respectively. The last
argument limits a number of games that will be played by Bonanza.
This command becomes effective when CSA_LAN macro is defined in
the Makefile.

  • dekunobou 'addr' 'port-dekunobou' 'port-bonanza'

This command connects Bonanza to Dekunobou.

  • display ['num']

This command prints the shogi board. If you want to flip the
board, set 'num' to 2. If not, set it to 1.

  • s

Bonanza makes a prompt reply while thinking as soon as this
command is used.

  • hash 'num'

This command is used to initialize the transposition table and
set the size of the table to 2^'num'.

  • hash learn create

This command is used to make a zero-filled position-lerning
database, "hash.bin". This command becomes effective when MINIMUM
macro is not defined in the Makefile.

  • hash learn on
  • hash learn off

These commands enable (on) or disable (off) the position learning.
The default is on.

  • learn 'str' 'steps' ['games' ['iterations' ['num1' ['num2']]]]

This command optimizes a feature vector of the static evaluation
function by using numorous experts' games in a single CSA record
file, "./records.csa". If you want to use a zero-filled vector as
an initial guess of the optimization procedure, set 'str' to
"ini". If not, set it to "no-ini". The third argument 'games' is a
number of games to be read from the record file. If the third
argument is negative or omitted, all games are read from the file.

The learning method iterates a set of procedures, and the number
of iteration can be limited by the fourth argument. It continues
as long as the argument is negative. The procedures consist of two
parts. The first part reads the record file and creates principal
variations by using 'num1' threads. The default value of 'num1' is
1. The second part renews the feature vector 'steps' times by using
'num2' threads in accord with the principal variations. The default
value of 'steps' and 'num2' is 1. Note that each thread in the
second procedure uses about 500MByte of the main memory. The two
arguments 'num1' and 'num2' become effective when TLP macro is
defined in the Makefile. After the procedures, the optimized
vector is saved in "./fv.bin". This command become effective when
MINIMUM macro is not defined in the Makefile.

  • limit depth 'num'

This command is used to specify a depth, 'num', at which Bonanza
ends the iterative deepening search.

  • limit nodes 'num'

When this command is used, Bonanza stops thinking after searched
nodes reach to 'num'.

  • limit time 'minute' 'second' ['depth']

This command limits thinking time of Bonanza. It tries to make
each move by consuming the time 'minute'. When the time is spent
all, it makes each move in 'second'. The last argument 'depth' can
be used if you want Bonanza to stop thinking after the iterative
deepening searches reach sufficient depth.

  • limit time extendable
  • limit time strict

The command, "limit time extendable", allows Bonanza to think
longer than the time limited by the previous command if it wishes
to. The default is "strict".

  • move ['str']

Bonanza makes a move of 'str'. If the argument is omitted, Bonanza
thinks of its next move by itself.

  • mpv num 'nroot'
  • mpv width 'threshold'

These commands control the number of root moves, 'nroot', to
constitute principal variations. The default number is 1. A root
move that yields a smaller value than the best value by 'threshold'
is neglected. The default threshold is about 200. These commands
become effective when MPV macro is defined in the Makefile.

  • new ['str']

This command initializes the shogi board. The argument 'str'
controls an initial configuration of the board. If you want to
play a no-handicapped game, set 'str' to "PI" and this is the
default value. In a handicapped game, specify squares and pieces
to drop, e.g. "new PI82HI22KA" or "new PI19KY".

  • peek on
  • peek off

The command "peek on (off)" enables (disables) peeks at a buffer
of the standard input file while Bonanza is thinking. The default
is on. This command is useful when you want to process a set of
commands as "> ./bonanza.exe < infile".

Prompt Bonanza to print "pong".

  • ponder on
  • ponder off

The command "ponder on (off)" enables (disables) thinks on the
opponent's time. The default is on.

  • problem ['num']

This command is used to solve problems in "./problem.csa". Here
is an example of the problem file.

                                                        • -

$ANSWER:+0024FU
P1-KY-KE-OU-KI * * * * -KY
P2 * * * * * -KI * * *
P3 * * -FU-GI-FU * -KE * -KA
P4-FU * * -FU-GI-FU-HI * -FU
P5 * * * * * * * -FU+KY
P6+FU+KA+FU+FU+GI+FU+KI * *
P7 * +FU * * +FU * * * *
P8 * +OU+KI+GI * * +HI * *
P9+KY+KE * * * * * +KE *
P+00FU00FU
P-00FU00FU00FU
+
/
$ANSWER:+0087KY:+0088KY
P1-OU-KE * * * * * +GI *
P2-KY-KI * * * * * * *
P3-FU-HI * -KI * * -GI * *
P4 * * -KE * * * * * -FU
P5 * +GI * -FU-FU-FU-FU-FU *
P6+FU+HI-FU * * * * * *
P7 * * * +FU * * * * +FU
P8 * * +OU+KI+KI * * * *
P9+KY+KE * * * * * +KE+KY
P+00KA00GI00KY00FU00FU
P-00KA00FU00FU00FU00FU00FU
+

                                                        • -

The argument 'num' specifies the number of problems to solve.

  • quit

The quit command and EOF character will exit Bonanza.

  • read 'filename' [(t|nil) ['num']]

This command is used to read a CSA record 'filename' up to 'num'
moves. Set the second argument to "nil" when you want to ignore
time information in the record. The default value is "t". Bonanza
reads all move sequence if the last argument is neglected. If
'filename' is ".", the command reads an ongoing game from the
initial position.

  • resign

Use this command when you resign a game.

  • resign 'num'

This command specifies the threshold to resign. 'num' is a value
of the threshold. The default is around 1000.

  • stress on
  • stress off

When the command "stress on" is used, last-move shown in shogi
board is stressed. The default is on.

  • time remain 'num1' 'num2'

This command tells Bonanza the remaining time. 'num1' ('num2') is
the remaining time of black (white) in seconds.

  • time response 'num'

This command specifies a margin to control time. The time margin
saves Bonanza from time up due to TCP/IP communication to a server
program, sudden disc access, or imperfection of time control of
Bonanza. 'num' is the time margin in milli-second. The default
value is 200.

  • tlp 'num'

This command controls the number of threads to be created when
Bonana considers a move to make. The command becomes effective
when TLP macro is defined in the Makefile. 'num' is the number of
threads. The default value is 1.

  • #

A line beginning with # causes all characters on that line
to be ignored.

  • [move command]

A move command consists of four digits followed by two
capital alphabets, e.g. 7776FU. The first two digits
are a starting square and the last two are a target square. The
starting square is "OO" if the move is a dorp, e.g. 0087FU. The
following two alphabets specify a piece type as the following,

FU - pawn (Fuhyo) TO - promoted pawn (Tokin)
KY - lance (Kyousha) NY - promoted lance (Narikyo)
KE - knight (Keima) NK - promoted knight (Narikei)
GI - silver general (Ginsho) NG - promoted silver (Narigin)
KI - gold general (Kinsyo)
KA - Bishop (Kakugyo) UM - Dragon horse (Ryuma)
HI - Rook (Hisha) RY - Dragon king (Ryuo)
OU - King (Osho)

Here, words in parentheses are romanization of Japanese words.

ボナンザのソースを読む。強さの秘訣は・・・

http://anchorage.2ch.net/test/read.cgi/bgame/1233229938/

解説ではないんだけど少しずつ解読しているスレ。
C言語に自信のある方は是非参加していただきたい。

ボナンザと言えば角切りだが
スタティックな評価はそれほど低くない。

■ボナンザの駒の価値
#define DPawn 101 /* 202 */
#define DLance 254 /* 508 */
#define DKnight 267 /* 534 */
#define DProPawn 503 /* 604 */
#define DProLance 424 /* 678 */
#define DProKnight 462 /* 729 */
#define DSilver 385 /* 770 */
#define DProSilver 477 /* 862 */
#define DGold 466 /* 932 */
#define DBishop 567 /* 1134 */
#define DRook 661 /* 1322 */
#define DHorse 831 /* 1398 */
#define DDragon 1002 /* 1663 */
#define DKing 15000

■YSSの駒の価値
3.2 駒の価値
駒の価値は表3の通りである。
4、5段目の値は、駒交換を計算する場合に用いる数値で、駒の価値の2倍、
成駒の場合は駒の価値の2倍+成った価値、となっている。
持ち駒については付加点を付けている。表は1枚目の付加点で、
枚数によっても点数を変えている。例えば金の場合は
1枚目+90、2枚目+40、3枚目+10、4枚目+0、と多く持つほど付加点を少なくしている。

表3 駒の価値
歩 香 桂 銀 金 角 飛
基本価値 100 430 450 640 690 890 1040
駒が成る価値 320 200 190 30 0 260 260
持駒の付加価値 15 50 60 80 90 220 230

駒交換用(基本) 200 860 900 1280 1380 1780 2080
(成駒) 520 1060 1090 1310 0 2040 2340

やはり中盤から終盤にかけて駒の価値というのは大きく変わるものなのだろう。

あと高速化のためにビット計算を多用しているようだ。

>評価関数は int evaluate( tree_t * restrict ptree, int turn ) で計算される
>最大52種類の何かの項目について make_list() で評価し、
>玉との相対位置を考慮して線形和を計算している

52種類!
残念ながらこの項目はソースには書かれていないようだ。

保木氏による解説があるとうれしいな・・・贅沢すぎるか。

Google急上昇ワードランキングブログパーツ

GIGAZINEに載っていた「Google急上昇ワードランキングブログパーツ
というサービス。

http://www.blogdeco.jp/google_word/

Google Trends(http://www.google.co.jp/trends/hottrends?sa=X)の結果を
ランキング上昇下降を付加して掲載するサービスらしい。

ちょっと自分でも作れるかやってみた。
実際に使うわけではないので
前回の更新との比較が出るだけのシンプルな作りにした。
本家は1日前とか出せるようだけど
差分ファイルを一つ作るだけで改造できるかと。

#!/usr/bin/perl

use strict;

my $log = 'trends.log';

my @trends;
my @html= `wget -O- -q 'http://www.google.co.jp/trends/hottrends?sa=X'`;

for my $l (@html){
if($l =~ m/num>(\d+)\..*X\">(.*)<\/a>/){
push(@trends,"$1\t$2\n");
}
}

my $outtxt;

if( -e $log ){
open my $fh , "<$log" or die ($?);

my @logtrends = <$fh>;

for my $t (@trends){
chomp $t;
my $rank;
my $word;

if($t =~ /(.*)\t(.*)/){
$rank = $1;
$word = $2;
}else{print "cant read $log";exit;}
my $logrank;
my $logword;

my $flag=1;
for my $logt (@logtrends){
chomp $logt;
if($logt =~ /(.*)\t(.*)/){
$logrank = $1;
$logword = $2;
}else{print "cant read $log";exit;}

if($logword eq $word){
my $diffrank = $logrank - $rank;

if($diffrank > 0){
#up
$outtxt .= $t . "\t" . "$diffrank UP!\n";
$flag = 0;

}elsif($diffrank < 0){
#down
$outtxt .= $t . "\t" . "$diffrank DOWN!\n";
$flag = 0;

}elsif($diffrank == 0){
#not change
$outtxt .= $t . "\t" . "-\n";
$flag = 0;

}
}
last if($flag == 0);
}
if($flag == 1){
$outtxt .= $t . "\t" . "NEW!\n"
}
}
}else{

open my $oh ,"> $log" or die($?);
print $oh @trends;
exit;
}
open my $oh ,"> $log" or die($?);
for my $oline (@trends){
print $oh $oline . "\n";
}
print $outtxt;

勝負脳

これも図書館にあった。
内容は・・・あまりおもしろくないかも。
コンピュータ将棋との対局、将棋連盟とは?などなど。
目新しいことは書かれていない。