12jun05abu
(c) Software Lab. Alexander Burger


         Pico Lisp Demo Games
         ====================

This directory contains a few simple games. They aren't especially interesting
or powerful, but may be useful programming examples.



'mine' is a simplified version of the minesweeper game. You can start it as:

$ ./p dbg.l games/mine.l -main -go

It will display a 12-by-12 field with 24 (default) hidden mines. You can move
around using the standard 'vi'-keys 'j' (down), 'k' (up), 'l' (right) and 'h'
(left).

Hit ENTER or SPACE to uncover a field, and ESC to terminate the game. In the
latter case (of if a mine exploded), you'll get the Pico Lisp prompt. Then you
can continue the game with

: (go)

possibly aftre re-initializing it with

: (main)

or quit the Pico Lisp interpreter with ENTER.



'nim' and 'ttt' are only testbeds for the general 'game' alpha-beta search
function (normally, these games are better implemented by directly exploring
their underlying principles and strategies).


Start Nim as

$ ./p dbg.l games/nim.l

and then find the the optimal move path for, let's say, three heaps of four
matches each:

: (nim 4 4 4)
-> (-100 ((1 . 4) 1 . -4) ((2 . 4) 2 . -4) ((3 . 4) 3 . -4))

This is a winning position (a minimal cost of -100), with three moves (in the
CARs of the move list: Take 4 from heap 1, then 4 from heap 2, and finally 4
from heap 3).


To play Tic-Tac-Toe, enter

$ ./p dbg.l games/ttt.l -main

A three-by-three board is displayed. Enter your moves with the 'go' function:

: (go a 1)
   +---+---+---+
 3 |   |   |   |
   +---+---+---+
 2 |   |   |   |
   +---+---+---+
 1 | T |   |   |
   +---+---+---+
     a   b   c

Your positions are marked with 'T', the computer's with '0'.



The 'chess' game is still under construction, and will be continued in future
releases. Currently, only the move logic is implemented, while the position
evaluation (the 'cost' function) is still very rudimentary.

Nevertheless, it plays some brainless chess. Start it as:

$ ./p dbg.l games/chess.l -main
   +---+---+---+---+---+---+---+---+
 8 |<R>|<N>|<B>|<Q>|<K>|<B>|<N>|<R>|
   +---+---+---+---+---+---+---+---+
 7 |<P>|<P>|<P>|<P>|<P>|<P>|<P>|<P>|
   +---+---+---+---+---+---+---+---+
 6 |   | - |   | - |   | - |   | - |
   +---+---+---+---+---+---+---+---+
 5 | - |   | - |   | - |   | - |   |
   +---+---+---+---+---+---+---+---+
 4 |   | - |   | - |   | - |   | - |
   +---+---+---+---+---+---+---+---+
 3 | - |   | - |   | - |   | - |   |
   +---+---+---+---+---+---+---+---+
 2 | P | P | P | P | P | P | P | P |
   +---+---+---+---+---+---+---+---+
 1 | R | N | B | Q | K | B | N | R |
   +---+---+---+---+---+---+---+---+
     a   b   c   d   e   f   g   h

The pieces are indicated by the letters 'K'ing, 'Q'ueen, 'R'ook, 'B'ishop,
k'N'ight and 'P'awn, with black pieces in angular brackets.

Enter your moves with the field names (in lower case) for the "from" and "to"
positions:

: (go e2 e4)

Castling may be entered by just specifying the king's move:

: (go e1 g1)

To undo one or several moves, enter

: (go -)

and to redo them

: (go +)

To switch sides (and have the computer play against itself), call 'go' without
arguments:

: (go)

The initial board position can be restored with

: (main)

and to setup some given board position, call 'main' with a list of triples for
the field, the piece's classes, and optionally a 'T' flag to indicate that the
piece did not move yet:

: (main
   (quote
      (a2 (+White +Pawn) T)
      (b1 (+White +King))
      (d4 (+Black +King)) ) )
   +---+---+---+---+---+---+---+---+
 8 |   | - |   | - |   | - |   | - |
   +---+---+---+---+---+---+---+---+
 7 | - |   | - |   | - |   | - |   |
   +---+---+---+---+---+---+---+---+
 6 |   | - |   | - |   | - |   | - |
   +---+---+---+---+---+---+---+---+
 5 | - |   | - |   | - |   | - |   |
   +---+---+---+---+---+---+---+---+
 4 |   | - |   |<K>|   | - |   | - |
   +---+---+---+---+---+---+---+---+
 3 | - |   | - |   | - |   | - |   |
   +---+---+---+---+---+---+---+---+
 2 | P | - |   | - |   | - |   | - |
   +---+---+---+---+---+---+---+---+
 1 | - | K | - |   | - |   | - |   |
   +---+---+---+---+---+---+---+---+
     a   b   c   d   e   f   g   h

The global variable '*Depth' holds the maximal depth of the alpha-beta tree
search. It defaults to 3. You may change it to some larger value for a deeper
search

: (setq *Depth 5)

or a smaller value for a faster response.
