public
Description: A perfect kalah player for up to 5 stones per bin
Homepage: http://naml.us/~irving/papers/irving2000_kalah.pdf
Clone URL: git://github.com/girving/kalah.git
kalah /
name age message
file .gitignore Tue Jul 21 07:46:15 -0700 2009 Compile fixes Switch default compile to serial... [girving]
file LICENSE Tue Jul 21 07:48:54 -0700 2009 Add a BSD license [girving]
file Makefile Tue Jul 21 07:46:15 -0700 2009 Compile fixes Switch default compile to serial... [girving]
file README Sat May 19 18:06:40 -0700 2001 Added .cvsignore [girving]
file classify.c Fri Jun 13 17:52:16 -0700 2003 Added failed file classify.c [girving]
file crunch.cilk Sun Jun 01 17:42:47 -0700 2003 Did some stuff. Don't really know what. [girving]
file crunch.cilkh Fri Mar 08 03:30:20 -0800 2002 Fixed twiddle and generator. [girving]
file elision.h Thu Jan 04 22:21:19 -0800 2001 Fixed bug in peek [girving]
file endgame.c Fri Jun 13 17:52:16 -0700 2003 Added failed file classify.c [girving]
file endgame.h Fri Jun 13 17:52:16 -0700 2003 Added failed file classify.c [girving]
file generator.c Fri Jun 13 17:52:16 -0700 2003 Added failed file classify.c [girving]
file hash.cilk Fri Mar 08 03:30:20 -0800 2002 Fixed twiddle and generator. [girving]
file hash.cilkh Fri Mar 08 03:30:20 -0800 2002 Fixed twiddle and generator. [girving]
file kalah.cilk Wed Jul 18 17:04:59 -0700 2001 Added check for Tie [girving]
file log.c Sun Dec 31 18:27:06 -0800 2000 Leaving moffit [girving]
file log.h Mon Dec 04 11:52:38 -0800 2000 Flattened directories and added parallel stuff [girving]
file mix.h Mon Dec 04 11:52:38 -0800 2000 Flattened directories and added parallel stuff [girving]
file parallel.c Sun Dec 31 18:27:06 -0800 2000 Leaving moffit [girving]
file parallel.h Sun Jun 01 17:42:47 -0700 2003 Did some stuff. Don't really know what. [girving]
file params.h Mon Dec 04 11:52:38 -0800 2000 Flattened directories and added parallel stuff [girving]
file protocol.txt Mon Dec 04 11:52:38 -0800 2000 Flattened directories and added parallel stuff [girving]
file rules.c Sun Jun 01 17:42:47 -0700 2003 Did some stuff. Don't really know what. [girving]
file rules.h Mon Dec 04 11:52:38 -0800 2000 Flattened directories and added parallel stuff [girving]
file twiddle.c Tue Jul 21 07:46:15 -0700 2009 Compile fixes Switch default compile to serial... [girving]
README
README file for kalah
Geoffrey Irving
2feb0

I wrote this very quickly, so it won't be very complete.

Compilation instructions:

  This code contains parallel versions of kalah for both
cilk and PVM.  The cilk version has been tested only on
2 processor machines and isn't fast, but seems to work,
while the PVM code is totally untested.  Both sets of
parallel code are controlled with macros, namely PVM
and NOCILK.  It should be easy to delete the PVM code
so that you don't have to work around it, and the cilk
code doesn't get in the way significantly.

  A normal make will try to build both cilk and serial
versions, and will therefore fail if you don't have cilk
installed.  "make serial" should build only the serial
version, and should work without cilk.  This will build
the programs kalah-s (-s means serial), generator, and
twiddle.

Explanation of generator:

  Normally, you want to give kalah an endgame database to
work with for speed.  I don't remember if this is optional
or not.  To build an endgame database, run generator.  It
takes one optional argument: the name of the database file,
which defaults to endgame.dat.  It will first ask for the 
number of bits to use for each entry, which can be 4 or 5.  
Usually you want 4, unless you're building a really huge 
database.  Now I will explain the commands:

Commands:
  h   - help
  i   - database info
  t n - size table to n stones
  r   - lookup a position's rate
  c n - complete table to n stones
  s   - save database
  q   - exit

The database will be immediately created with no information
in it.  Commands 'h', 'i', 's', and 'q' are self-explanatory,
except that 'q' automatically runs 's'.

't' generates a table of the space taken up by databases of
certain size.  Since the database is loaded entirely into
memory, this is really important.  The first two columns are
for 4 bits, and the second two are for 5.  An entry "n) x,y" means
x bytes to store only the n stone part, and y bytes for n and
fewer.  Normally only y is important.  "c n" will then generate
the database in memory, but will not save it until 's' is run.

Explanation of kalah:

  Here is what kalah-s with no arguments prints, since it doesn't
bother to realize it's serial when calling usage().

Usage: kalah [OPTIONS] s n
       kalah [OPTIONS] p p0 ... p13
Starting commands:
  s n    start with n stones in each pit
  p ...  start with explicit position
Options:
  -d n   search depth (default 200)
  -r n   guess for minimax value
  -j     skip iterative deepening
  -l     single test call at full depth
  -g     play a complete game
  -v     verbose output
  -V     extremely verbose output
  -t n   transposition table size (required)
  -e n   endgame database size (required)
  -T f   tranposition table file (defaults to none)
  -E f   endgame database file (defaults to endgame.dat)
Examples:
  kalah -vt 20 -e 18 s 3

As shown, kalah takes options and then start position information,
which is given either explicitly or via "s n" for a normal initial
configuration.  Then it computes minimax values and optimal moves
as specified by the options.  Here is a partial explanation of options:

"-d n" and "-j" should be self explanatory.  "-r n" changes the default
first guess "f" in MTD(f) (the default is the rating of the start position).
-l short circuits MTD(f) after one computation, and thus computes only a lower
or upper bound.  "-g" switches between both players computing moves until the
game completes.  "-v" gives status information as the algorithm proceeds, which
is almost essential for long searches.  "-V" provides more.  "-t n" and "-e n"
provide the transposition table size in bits, and the endgame database size in
stones.  The actual size of the transposition table will be 12*2^n bytes, and
the endgame database size can be found by running generator.  "-E f" is clear.
If "-T f" is unspecified, the program never reads or writes the transposition
table to disk.  With "-T f", it does.