Skip to content
A fairly strong Go/Baduk/Weiqi playing program
C Python Turing C++ Perl Shell Makefile
Branch: master
Clone or download

Latest commit

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
distributed distributed: fixed engine init, forgot to convert it in <gtp_setoptio… Apr 8, 2020
engines cleanup: use board_to_play() instead of stone_other(last_move(b)) May 14, 2020
gtp Makefile cleanup, file perms, .gitignore, moved tools/*.gtp to gtp/ Sep 8, 2017
joseki joseki: sgf database Nov 4, 2018
kgs --kgs-chat: enable kgs-chat command (disabled by default now) Apr 19, 2020
media README: run pachi inside lizzie ! Feb 8, 2019
pattern README Nov 6, 2018
playout moggy speedup: avoid double_to_fixp() conversions in playouts Mar 22, 2019
t-play autotest-show: formatting fix, ELO: EGF formula, show stones Aug 31, 2018
t-predict types: use typedefs instead of struct Mar 22, 2019
t-regress mm: atari_and_cap / wouldbe_ladder_any() fix Mar 30, 2019
t-unit t-unit: moggy status cleanup May 29, 2020
tactics board_earliest_pass(): fixed <new_board> PR bug, values were wrong ! Apr 8, 2020
tools tools: fixed gtp2board_print May 30, 2020
uct windows: fixed printf warnings May 20, 2020
.gitignore build: include git hash and branch in version Nov 18, 2017
.mingw32_dlls build: mingw caffe support Feb 11, 2018
.mingw64_dlls build: mingw caffe support Feb 11, 2018
.travis.yml dcnn: renamed detlef dcnn files, abort if dcnn not found Mar 22, 2019
ANDROID.txt Fix build in packaging systems like portage or debian Dec 16, 2013
COPYING Licence: Relicence all Pachi from MIT to GPLv2 Dec 11, 2009
CREDITS CREDITS Mar 30, 2019
HACKING uct cleanup: removed local trees, moving to local_tree branch May 20, 2020
INSTALL.md Update INSTALL.md May 11, 2019
MORE.md tree realloc: "tree_size", "max_tree_size", "max_mem" uct params May 19, 2020
Makefile Makefile: packaging cleanup Apr 8, 2020
Makefile.lib Makefile: sane CFLAGS / CXXFLAGS Mar 1, 2019
Makefile.linux Makefile: split out arch specific stuff Mar 1, 2019
Makefile.mac Makefile: split out arch specific stuff Mar 1, 2019
Makefile.msys2 windows: gnugo dead stones support Apr 3, 2020
README.md README: Lizzie 0.7.2 setup May 23, 2020
TODO Pachi 12.40 Mar 31, 2019
board.c logs: show final score and ownermap Apr 3, 2020
board.h cleanup: use board_to_play() instead of stone_other(last_move(b)) May 14, 2020
board_play.h board: board_size() redefinition Mar 22, 2019
board_undo.c board: last moves array Mar 22, 2019
board_undo.h board_undo speedup Mar 22, 2019
book.dat.bad book.dat*: Tweak based on 9x9 computer olympiad Nov 22, 2011
book.dat.extra book.dat*: Tweak based on 9x9 computer olympiad Nov 22, 2011
caffe.cpp dcnn: multiple dcnn support Mar 22, 2019
caffe.h dcnn: multiple dcnn support Mar 22, 2019
chat.c all: strbuf init macro Mar 22, 2019
chat.h types: use typedefs instead of struct Mar 22, 2019
dcnn.c dcnn: darkforest dcnn support Mar 22, 2019
dcnn.h dcnn: darkforest dcnn support Mar 22, 2019
debug.h Header guards: Rename ZZGO_* to PACHI_* Apr 16, 2011
engine.c windows: gnugo dead stones support Apr 3, 2020
engine.h --accurate-scoring: use gnugo to compute dead stones at the end Mar 28, 2020
fbook.c board: board_new()/board_delete(), board_copy()/board_done() Mar 22, 2019
fbook.h types: use typedefs instead of struct Mar 22, 2019
fifo.c c++ fixes Mar 22, 2019
fifo.h require macro stubs to have a non-empty expansion Nov 4, 2018
fixp.h Header guards: Rename ZZGO_* to PACHI_* Apr 16, 2011
genbuild build: gitversion.h -> build.h Feb 11, 2018
gogui.c cleanup: use board_to_play() instead of stone_other(last_move(b)) May 14, 2020
gogui.h gogui: adjusted best moves values Mar 22, 2019
gtp.c lz-analyze: handle pondering + analyzing May 15, 2020
gtp.h lz-analyze: keep state when toggling analyze on/off May 14, 2020
joseki.c engine: store parsed options Mar 31, 2019
joseki.h c++ fixes Mar 22, 2019
joseki19.gtp joseki: sgf database Nov 4, 2018
move.c util.h: const-safe versions of strchr() and friends Mar 31, 2019
move.h board: board_size() redefinition Mar 22, 2019
mq.h moggy speedup: avoid double_to_fixp() conversions in playouts Mar 22, 2019
network.c c++ fixes Mar 22, 2019
network.h network: compile time switch Mar 1, 2019
ownermap.c board_print_ownermap(): fixed typos Apr 8, 2020
ownermap.h board_earliest_pass(): fixed <new_board> PR bug, values were wrong ! Apr 8, 2020
pachi.c tree realloc: "tree_size", "max_tree_size", "max_mem" uct params May 19, 2020
pachi.h kgs: --nopassfirst only applies to chinese rules games Apr 8, 2020
pattern.c t-unit: spatial regtest fix Mar 30, 2019
pattern.h t-unit: spatial regtest fix Mar 30, 2019
pattern3.c pat3 cleanup Mar 22, 2019
pattern3.h pat3 cleanup Mar 22, 2019
patternprob.c pattern: fixed floating_t issue, DOUBLE_FLOATING ok now Apr 8, 2020
patternprob.h pattern: fixed floating_t issue, DOUBLE_FLOATING ok now Apr 8, 2020
patterns_mm.gamma mm: atari_and_cap / wouldbe_ladder_any() fix Mar 30, 2019
patterns_mm.spat mm: new patterns_mm.spat, patterns_mm.gamma: 37% prediction rate now Sep 25, 2018
patternsp.c pattern speedup Mar 22, 2019
patternsp.h mm: notes, debugging Mar 30, 2019
playout.c board speedup: don't update history / symmetry during playouts Mar 22, 2019
playout.h c++ fixes Mar 22, 2019
random.c windows: don't include <windows.h> everywhere, builds 3x faster Apr 8, 2020
random.h fast_frandom() always returns float, not floating_t May 18, 2012
spudfrog joseki: spatial pattern based engine Nov 4, 2018
stats.h types: use typedefs instead of struct Mar 22, 2019
stone.c Initial commit - basics work, but below idiotbot level Nov 11, 2007
stone.h Header guards: Rename ZZGO_* to PACHI_* Apr 16, 2011
timeinfo.c --fuseki-time stops after move 10 instead of 20, helps with joseki tr… Apr 8, 2020
timeinfo.h c++ fixes Mar 22, 2019
util.c windows: don't include <windows.h> everywhere, builds 3x faster Apr 8, 2020
util.h windows: don't include <windows.h> everywhere, builds 3x faster Apr 8, 2020
version.h Pachi 12.50 May 20, 2020

README.md

Pachi

Pachi can refer to: a simple modular framework for programs playing the game of Go/Weiqi/Baduk, and a reasonably strong engine built within this framework.

Engine

The default engine plays by Chinese rules and should be about 7d KGS strength on 9x9. On 19x19 it can hold a solid KGS 2d rank on modest hardware (Raspberry Pi, dcnn) or faster machine (e.g. six-way Intel i7) without dcnn.

When using a large cluster (64 machines, 20 cores each), it maintains KGS 3d to 4d and has won e.g. a 7-stone handicap game against Zhou Junxun 9p.

By default, Pachi currently uses the UCT engine that combines Monte Carlo approach with tree search; UCB1AMAF tree policy using the RAVE method is used for tree search, while the Moggy playout policy using 3x3 patterns and various tactical checks is used for the semi-random Monte Carlo playouts. MM patterns are used in the tree search.

Binary Releases

Linux / Windows: Download binary release and follow instructions inside.

Ubuntu: Install 'pachi-go' package from ppa:

sudo add-apt-repository ppa:lemonsqueeze/pachi
sudo apt-get update
sudo apt-get install pachi-go

Performance might be better if you recompile for your own system though.

For build instructions see INSTALL.

Setup

The pachi binary program is a GTP client. Use it with your favorite Go program interface (e.g. gogui, sabaki, lizzie), or use kgsGtp to connect it to KGS.

DO NOT make the GTP interface accessible directly to untrusted users since the parser is not secure - see the HACKING file for details.

The pachi program can take many parameters. The defaults should be fine for initial usage, see below for more tips.

Deep Learning

Pachi uses a neural network as source of good moves to consider (policy network). With dcnn support Pachi can play at dan level on modest hardware. For large number of playouts this makes it about 1 stone stronger and makes the games more pretty. A raw dcnn engine is available for pure dcnn play (not recommended for actual games, pachi won't know when to pass or resign !).

pachi --list-dcnn  List supported networks.
pachi --dcnn=name  Choose network to use (Detlef's 54% dcnn by default).

Releases come with Detlef's 54% dcnn by default. For other networks see Pachi Networks.

Currently dcnn is used for root node only.

How to run

By default Pachi will run on all cores, using up to 200Mb of memory for tree search and taking a little under 10 seconds per move. You can adjust these parameters by passing it extra command line options.

For main options description try:

    pachi --help

Time Settings

Pachi can smartly deal with a variety of time settings (canadian byoyomi recommended to maximize efficient time allocation). However, most of these are accessible only via GTP, that is by the frontend keeping track of time, e.g. KGS or gogui.

It's also possible to force time settings via the command line (GTP time settings are ignored then):

  • pachi -t 20          20s per move.
  • pachi -t _600         10 minutes sudden death.
  • pachi -t =5000         5000 playouts per move.
  • pachi -t =5000:15000     Think more when needed. Same but up-to 15000 playouts if best move is unclear.
  • pachi -t =5000:15000 --fuseki-time =4000  Don't think too much during fuseki.

Fixed Strength

Pachi will play fast on a fast computer, slow on a slow computer, but strength will remain the same:

  • pachi -t =5000:15000 --dcnn=df   kgs 3d
  • pachi -t =5000:15000          kgs 2d
  • pachi -t =5000 --nodcnn         kgs 3k (mcts only).

KGS

Use pachi --kgs when playing on KGS. See kgsgtp.conf for example.

Other Options

  • pachi resign_threshold=0.25  Resign when winrate < 25% (default: 20%).

  • pachi reportfreq=1s  Show search progress every second (default: 1000 playouts).

  • pachi -t 10 threads=4,max_tree_size=100

    Play with 10s per move on 4 threads, taking up to 100Mb of memory (+ several tens Mb as a constant overhead).

  • pachi -t _1200 --nodcnn threads=8,max_tree_size=3072,pondering

    Play without dcnn with time settings 20:00 S.D. on 8 threads, taking up to 3Gb of memory, and thinking during the opponent's turn as well.

Pachi 12.50 Note: By default Pachi automatically allocates memory for tree search now so you shouldn't have to set "max_tree_size" anymore unless you want to limit max memory used. See here for details.

For now, there is no comprehensive documentation of engine options, but you can get a pretty good idea by looking at the uct_state_init() function in uct/uct.c - you will find the list of UCT engine options there, each with a description. At any rate, usually the four options above are the only ones you really want to tweak.

Analyze commands

When running Pachi through GoGui, a number of graphic tools are available through the Tools -> Analyze commands window:

  • Best moves
  • Score estimate
  • DCNN ratings ...

It's also possible to visualize best moves / best sequence while Pachi is thinking via the live gfx commands.

score estimate dcnn colormap

For game analysis try GoReviewPartner, or see here for some tools that come with Pachi.

Lizzie

It's also possible to run Pachi with Lizzie to analyze things !
This is a great way to explore variations, analyze games or visualize what Pachi is doing while it's thinking, the graphics are amazing.

Setup:

  • Install Lizzie 0.7.2

  • Download Pachi 12.50, extract in Lizzie folder

  • Configure engines:
    Start Lizzie, Menu -> Settings -> Engine
    Add Pachi as "Engine 2":

    Engine 2:  ./pachi/pachi.exe -o pachi.log
    

    Normally Leela-zero and Katago are Default Engine and Engine 1.

  • Lizzie will start with Leela-zero by default,
    use Menu -> Engine -> Engine 2 to switch to Pachi.
    (Window title shows current engine).

Logs

Pachi logs details of its activity on stderr, which can be viewed via Tools -> GTP Shell in gogui. Tons of details about winrates, memory usage, score estimate etc can be found here. Even though most of it available through other means in gogui, it's always a good place to look in case something unexpected happens.

-d <log_level> changes the amount of logging (-d0 suppresses everything)
-o log_file logs to a file instead. gogui live-gfx commands won't work though.

More

See HACKING for a more detailed developer's view of Pachi,
MORE for more details, other engines and game analysis tools.

Also, if you are interested about Pachi's architecture, algorithms etc., consider taking a look at Petr Baudis' Master's Thesis:

http://pasky.or.cz/go/prace.pdf

...or a slightly newer scientific paper on Pachi:

http://pasky.or.cz/go/pachi-tr.pdf

Licence

Pachi is distributed under the GPLv2 licence (see the COPYING file for details and full text of the licence); you are welcome to tweak it as you wish (contributing back upstream is welcome) and distribute it freely, but only together with the source code. You are welcome to make private modifications to the code (e.g. try new algorithms and approaches), use them internally or even to have your bot play on the internet and enter competitions, but as soon as you want to release it to the public, you need to release the source code as well.

One exception is the Autotest framework, which is licenced under the terms of the MIT licence (close to public domain) - you are free to use it any way you wish.

You can’t perform that action at this time.