Add support for situation analysis: uct_evaluate
[pachi/ann.git] / README
blob2ce2f41e6daf9aaf51057f0e855e225d382bba0d
1 Pachi is two things: a simple modular framework for robots playing
2 the game of Go/Weiqi/Baduk, and a reasonably strong engine built
3 within this framework.
6 Engine
7 ------
9 By default, Pachi currently uses the UCT engine that combines
10 monte-carlo approach with tree search; UCB1AMAF tree policy using
11 the RAVE method is used for tree search, while the Moggy playout
12 policy using 3x3 patterns and various tactical checks is used for
13 the random Monte-Carlo playouts.
15 The default engine plays by Chinese rules and should be about
16 2d KGS strength on 9x9. On 19x19, it might be about KGS 4k. Of couse,
17 this assumes reasonable hardware, e.g. four-threaded Core2 machine.
19 At the same time, various other approaches and tricks are being tried
20 and minor improvements have been achieved; they are enabled when they
21 give an universal playing strength boosts.
24 Except UCT, Pachi supports a simple idiotbot-like engine and an example
25 treeless MonteCarlo-player. The MonteCarlo simulation ("playout")
26 policies are also pluggable, by default we use one that makes use of
27 heavy domain knowledge.
29 Two special engines are also provided for development support:
30 * a simple "replay" engine that will simply play moves according
31   to the playout policy suggestions
32 * a special "patternscan" engine that will respond to 'play' commands
33   by iteratively matching various pattern features on each move and
34   outputting them as response to the command; it is intended to be
35   used for pattern-learning from games in cooperation with an external
36   helper; no 'genmove' command support is provided
39 Analysis
40 --------
42 Pachi can also help you analyze your games, by being able to provide
43 its opinion on various positions. The user interface is very rudimentary,
44 but the ability is certainly there.
46 There are currently two Pachi interfaces for this purpose. One
47 possibility is to evaluate all moves within a given game and show how
48 the winrates for both players evolved - i.e. who was winning at which
49 game stage. This is implemented using the `sgf-analyse.pl` script. See
50 the comment on top of the script about its usage.
52 Alternatively, Pachi can evaluate all available moves in a given situation
53 and for each give a value between 0 and 1 representing perceived
54 likelihood of winning the game if one would play that move. I.e. it can
55 suggest which moves would be good and bad in a single given situation.
57 To achieve the latter, follow few simple steps:
59 1. Take an SGF record of your game and generate a GTP file from it:
61         ./sgf2gtp.pl <file.sgf >file.gtp
63 2. Open the file.gtp in your favorite plaintext editor and trim it after
64 (remove all lines following) the move producing the situation you wish
65 to analyze.
67 3. Instead, add the following line at the bottom of file.gtp:
69         0 uct_evaluate black
71 (replace `black` with `white` if it is white to play).
73 4. Run Pachi as follows:
75         ./zzgo -t =500 -d 0 <file.gtp | sed -n '/^=0/,${s/^=0 //;p}'
77 If you want to know more details on what is Pachi thinking about the
78 various moves, remove the `-d 0` and `| sed -n ...` parts. To improve
79 the accuracy of values (at the expense of run time), raise the value
80 of 500 (try 2000 or 10000; 100000 will usually already take couple of
81 hours). The values will be most useful in the middle game; in fuseki
82 and most yose situations, expect a lot of noise.
85 Framework
86 ---------
88 The aim of the framework is to make it easy to plug your engine
89 to the common infrastructure and implement your ideas while
90 minimalizing the overhead of implementing the GTP, speed-optimized
91 board tools, etc.  Also, there are premade random playout and UCT
92 tree engines, so that you can directly tweak only particular policies.
93 The infrastructure is pretty fast and it should be quite easy
94 to extend it to provide more facilities for your engine (but it should
95 be at the same time kept as simple as possible).
98 Licence
99 -------
101 Pachi is distributed under the GPLv2 licence (see the COPYING file for
102 details and full text of the licence); you are welcome to tweak it as
103 you wish (contributing back upstream is welcome) and distribute
104 it freely, but only together with the source code. You are welcome
105 to make private modifications to the code (e.g. try new algorithms and
106 approaches), use them internally or even to have your bot play on the
107 internet and enter competitions, but as soon as you want to release it
108 to the public, you need to release the source code as well.
110 One exception is the Autotest framework, which is licenced under the
111 terms of the MIT licence (close to public domain) - you are free to
112 use it any way you wish.
115 To build Pachi, simply type:
117         make
119 Built zzgo binary (named that way from historical reasons) in the current
120 directory is a GTP client; use your favorite Go client to connect to it
121 (generally it should be possible to use it in place of GNU Go; the
122 command-line usage is however different), or use kgsGtp to connect to KGS;
123 DO NOT make it accessible directly to enemy users since the parser is
124 not secure - see the HACKING file for details.
126 The zzgo binary can take many parameters, as well as the particular
127 engine being used; the defaults should be fine for initial usage,
128 you will have to consult the sources for fine-tuning the parameters.
130 To build better optimized binary, type:
132         make zzgo-profiled
134 This will also create binary zzgo, but while the build will take
135 more time (probably less than a minute anyway), the resulting binary
136 will be about 1/4 to 1/5 faster.