UCT: Introduce 'maximize_score' preset that turns on adaptive dynkomi, val_scale...
[pachi.git] / README
blob8afda7323c42cf0b2f52577b49427d7283aa2487
1 Pachi can refer to: a simple modular framework for programs playing
2 the game of Go/Weiqi/Baduk, and a reasonably strong engine built
3 within this framework.
6 Installation
7 ------------
9 To build Pachi, simply type:
11         make
13 The resulting binary program `pachi` is a GTP client; connect to it
14 with your favorite Go program interface (e.g. gogui or qgo), or use
15 kgsGtp to connect it to KGS.  (DO NOT make the GTP interface accessible
16 directly to untrusted users since the parser is not secure - see the
17 HACKING file for details.)
19 The pachi program can take many parameters, as well as the particular
20 engine being used; the defaults should be fine for initial usage,
21 see below for some more tips.
23 In case you hit compilation issues (e.g. when building on MacOS/X)
24 or want to change the build configuration, check the user configurable
25 section at the top of the Makefile.
28 Engine
29 ------
31 The default engine plays by Chinese rules and should be about
32 3d KGS strength on 9x9. On 19x19, it might be about KGS 2k, assuming
33 reasonable hardware, e.g. two-core Athlon64 machine.  On a higher-end
34 (e.g. six-way Intel i7) machine, it can hold a solid KGS 1d rank.
35 When using a large cluster (64 machines, 20 cores each), it maintains
36 KGS 3d and has won a 7-stone handicap game against Zhou Junxun 9p.
38 By default, Pachi currently uses the UCT engine that combines
39 Monte Carlo approach with tree search; UCB1AMAF tree policy using
40 the RAVE method is used for tree search, while the Moggy playout
41 policy using 3x3 patterns and various tactical checks is used for
42 the semi-random Monte Carlo playouts.
44 At the same time, we keep trying a wide variety of other approaches
45 and enhancements. Pachi is an active research platform and quite a few
46 improvements have been already achieved. We rigorously play-test new
47 features and enable them by default only when they give a universal
48 strength boost.
50 How to run
51 ~~~~~~~~~~
53 By default, Pachi will run on a single CPU core, taking up to 1.4GiB
54 of memory, not pondering and taking completely arbitrary amount of time
55 per turn. You can adjust these parameters by passing it extra command
56 line options:
58         ./pachi -t _1200 threads=8,max_tree_size=3072,pondering
60 This will make Pachi play with time settings 20:00 S.D. (unless it
61 gets told otherwise over GTP), with 8 threads, taking up to 3GiB
62 of memory (+ several tens MiB as a constant overhead) and thinking
63 during the opponent's turn as well.
65 Pachi can use an opening book in a Fuego-compatible format - you can
66 obtain one at http://gnugo.baduk.org/fuegoob.htm and use it in Pachi
67 with the -f parameter:
69         ./pachi -f book.dat ...
71 You may wish to append some custom Pachi opening book lines to book.dat;
72 take them from the book.dat.extra file. If using the default Fuego book,
73 you may want to remove the lines listed in book.dat.bad.
75 Pachi can also use a pattern database to improve its playing performance.
76 You can get it at http://pachi.or.cz/pat/ - you will also find further
77 instructions there.
79 For now, there is no comprehensive documentation of options, but you
80 can get a pretty good idea by looking at the uct_state_init() function
81 in uct/uct.c - you will find the list of UCT engine options there, each
82 with a description. At any rate, usually the three options above are
83 the only ones you really want to tweak.
85 Greedy Pachi
86 ~~~~~~~~~~~~
88 Normally, Pachi cares only for win or loss and does not take into
89 account the point amount. This means that it will play slack endgame
90 when winning and crazy moves followed with a resign when losing.
92 It may give you a more pleasurable playing experience if Pachi
93 _does_ take into account the point size, strives for a maximum
94 (reasonable) win margin when winning and minimal point loss when
95 losing. This is possible by using the maximize_score parameter, e.g.:
97         ./pachi -t _1200 threads=8,pondering,maximize_score
99 This enables an aggressive dynamic komi usage and end result margin
100 is included in node values aside of winrate. Pachi will also enter
101 scoring even when losing (normally, Pachi will never pass in that case).
102 Note that if you pass any 'dynkomi' parameter to Pachi, you will reset
103 the values set by 'maximize_score'.
105 Note that Pachi in this mode may be slightly weaker, and result margin
106 should not be taken into account when judging either player's strength.
108 Experiments and Testing
109 ~~~~~~~~~~~~~~~~~~~~~~~
111 Except UCT, Pachi supports a simple idiotbot-like engine and an example
112 treeless MonteCarlo-player. The MonteCarlo simulation ("playout")
113 policies are also pluggable, by default we use the one that makes use of
114 heavy domain knowledge.
116 Other special engines are also provided:
117 * a "distributed" engine for cluster play; the description at the top of
118   distributed/distributed.c should provide all the guidance
119 * a simple "replay" engine that will simply play moves according
120   to the playout policy suggestions
121 * a simple "patternplay" engine that will play moves according to the
122   learned patterns
123 * few other purely for development usage
125 Pachi can be used as a test opponent for development of other go-playing
126 programs. For example, to get the "plainest UCT" player, use:
128         ./pachi -t =5000 policy=ucb1,playout=light,prior=eqex=0,dynkomi=none
130 This will fix the number of playouts per move to 5000, switch the node
131 selection policy from ucb1amaf to ucb1 (i.e. disable RAVE), switch the
132 playouts from heuristic-heavy moggy to uniformly random light, stop
133 prioring the node values heuristically, and turn off dynamic komi.
135 You can of course selectively re-enable various features or tweak this
136 further. But please note that using Pachi in this mode is not tested
137 extensively, so check its performance in whatever version you test
138 before you use it as a reference.
140 Note that even in this "basic UCT" mode, Pachi optimizes tree search
141 by considering board symmetries at the beginning. Currently, there's no
142 easy option to turn that off. The easiest way is to tweak board.c so
143 that board_symmetry_update() has goto break_symmetry at the beginning
144 and board_clear has board->symmetry.type = SYM_NONE.
147 Analysis
148 --------
150 Pachi can also help you analyze your games by being able to provide
151 its opinion on various positions. The user interface is very rudimentary,
152 but the ability is certainly there.
154 There are currently several Pachi interfaces provided for this purpose.
156 Winrate Development
157 ~~~~~~~~~~~~~~~~~~~
159 Pachi can evaluate all moves within a given game and show how
160 the winrates for both players evolved - i.e. who was winning at which
161 game stage. This is implemented using the `tools/sgf-analyse.pl` script.
162 See the comment on top of the script about its usage.
164 Move Ranking
165 ~~~~~~~~~~~~
167 Pachi can evaluate all available moves in a given situation
168 and for each give a value between 0 and 1 representing perceived
169 likelihood of winning the game if one would play that move. I.e. it can
170 suggest which moves would be good and bad in a single given situation.
172 To achieve the latter, note the number of move at the situation you
173 want to evaluate and run the `tools/sgf-ratemove.sh` script.
174 See the comment on top of the script about its usage.
176 Pattern Move Hinting
177 ~~~~~~~~~~~~~~~~~~~~
179 Pachi can show instantenous pattern-based move suggestions very much
180 like for example Moyo Go Studio (though of course without a GUI).
181 You can use the Move Ranking method above (tools/sgf-ratemove.sh),
182 but pass it an extra parameter '-e patternplay'.
185 Framework
186 ---------
188 The aim of the software framework is to make it easy to plug your
189 engine to the common infrastructure and implement your ideas while
190 minimalizing the overhead of implementing the GTP, speed-optimized
191 board implementation, etc.  Also, there are premade random playout
192 and UCT tree engines, so that you can directly tweak only particular
193 policies.  The infrastructure is pretty fast and it should be quite
194 easy for you (or us) to extend it to provide more facilities for
195 your engine.
197 See the HACKING file for a more detailed developer's view of Pachi.
199 Also, if you are interested about Pachi's architecture, algorithms
200 etc., consider taking a look at Petr Baudis' Master's Thesis:
202         http://pasky.or.cz/go/prace.pdf
205 Licence
206 -------
208 Pachi is distributed under the GPLv2 licence (see the COPYING file for
209 details and full text of the licence); you are welcome to tweak it as
210 you wish (contributing back upstream is welcome) and distribute
211 it freely, but only together with the source code. You are welcome
212 to make private modifications to the code (e.g. try new algorithms and
213 approaches), use them internally or even to have your bot play on the
214 internet and enter competitions, but as soon as you want to release it
215 to the public, you need to release the source code as well.
217 One exception is the Autotest framework, which is licenced under the
218 terms of the MIT licence (close to public domain) - you are free to
219 use it any way you wish.