HsTZAAR

HsTZAAR is a computer program to play TZAAR, a 2-player abstract strategy game designed by Kris Burm and the final game in the GIPF project. HsTZAAR is written in Haskell and allows for local play against a computer AI; it also provides a good interface for programmers to implement diferent AI strategies.

This program was based on the htzaar by Tom Hawkins. In 2010, I started experimenting with classical AI techniques for TZAAR and implemented them on-top of htzaar; since the later package is no longer updated, I decided to start HsTZAAR.

The main features are:

Because of the combinatorial explosion, the AI is slow at depths greater 3. The default choice (negascout with ply 3 and simple evaluation) is not too hard to beat. For more a challenging opponent choose ply 3 and full evaluation; for an easier game, choose ply 1 and the simple evaluation.

Requirements

HsTZAAR requires a resonably recent GHC compiler (version 7 or newer) plus the gtk2hs, cairo and glade libraries. It was tested on an Ubuntu GNU/Linux system, and should compile and run fine on other Linuxes. I also verified that it compiles under Mac OS X (snow leopard) and Windows XP.

The hardware requirements are quite modest and should include any modern desktop or laptop. In fact, it compiles and runs fine on the Raspberry Pi (though compilation takes much longer than my laptop)!

Download

Source code

You can download the source package from HackageDB site. To compile and install use the following shell commands (where x.y is the package version):

$ tar xvzf hstzaar-x.y.tar.gz
$ cd hstzaar-x.y
$ runhaskell Setup.hs configure
$ runhaskell Setup.hs build
$ runhaskell Setup.hs install

You can also download and install in one step using the Cabal install tool:

cabal install hstzaar

Cabal installs in your home directory by default; you can do a global install with the --global flag. In that case both the binary and an XML file with GUI data will be installed in a system wide locations (e.g. /usr/local/bin and /usr/local/share/hstzaar).

Binaries

For the benefit of users who don't want to install Haskell development tools, I have prepared a Windows 32-bit installer: hstzaar-0.9.1-setup.exe.

This also installs the necessary GTK+ runtime libraries on the program's private directory but does not install anything into system directories.

Enabling parallelism

To use the parallel AI you must first enable the Haskell multi-threaded execution using a command-line option (if you forget this step, the parallel algorithm runs on a single core which will actually be slower):

$ hstzaar +RTS -Nnum -RTS   # run using num cores
$ hstzaar +RTS -N -RTS      # run on all available cores

Choose one of the parallel AIs on the options menus. On my 4-core desktop, I measured a 2x speedup using pscout_full_3 compared to the sequential nscout_full_3.

Batch-mode tournaments

You can also run two AIs against each other in batch mode (useful for comparing relative strength or measuring speedups), e.g. to run a tournament on 10 random boards, each board played twice (exchanging black and white players):

$ hstzaar nscout_simple_3 nscout_full_1
...lengthy output ommitted...
nscout_simple_3 vs nscout_full_1: -14 (0 matches won and 14 lost)
In this case, negascout with full evaluation has beaten a higher-depth simple evaluation 14 times and never lost (it is considered a draw if both win when exchanging starting player).

You can also specify the number of games to run or the pseudo random-seed (to ensure repeatability); check all command line options using hstzaar --help.

Feedback

Please contact me you enjoy this game or if you have some suggestion. I'm particularly interested in remarks on how the AI plays and suggestions on how to make better.

External links


Pedro Vasconcelos, pbv at dcc dot fc dot up dot pt
Departamento de Ciência de Computadores
Faculdade de Ciências da Universidade do Porto
PORTUGAL