
		Zenix (implementation by David GLAUDE glu@who.net)

This is a computer for Play By eMail of the game Zenix distributed by Gigamic.

	---BEGIN of DISCLAMER---

Long ago I released this game with the name Xeniz because I was
afraid Gigamic won't be happy to see peaple playing freely the game
they distribute (and what should I say about the author of the game).

So I released a "clone" with a different name and my own wording
of the rules. This was a way to avoid copyright and trademark issue.
More likely there is no patent on the game Zenix.

Recently it was announce that Gigamic agree for all of their game
to be implemented in PBeM version.

So let my code be available and be played by PBeM community.

However, just to make sure...
If you are the author/distributor or legal representative and feel there is
 * an issue for me to release this code, please contact me to discuss it :
   David GLAUDE (Belgium) glu@who.net http://glu.freeservers.com
 * an issue for someone else to run this code on a PBeM server, please contact
   the owner of this server (and he will more likely stop that and seek legal
   advice)

Please read the COPYING file for the copyright licence of the code provided.
My code is release under the GPL licence.

	---END of DISCLAMER---

RULES:
The board of this game is a vertical pyramid of a given size.
In this game, gravity matters.

             1- .
            2- . .
           3- . . .
          4- . . . .
         5- . . . . .
        6- . . . . . .
       7- . . . . . . .
      8- . . . . . . . .
          \ \ \ \ \ \ \ \
           A B C D E F G H

Each player own a certain number of pieces and a smaller number of
neutral piece. Each player in turn place one piece (own or neutral)
of it's own stock on the board.
A piece placed on the board must be in a stable position (using the
gravity definition of stable). This mean it must be on the bottom row
of the board or have two other pieces just below, one on the left and
one on the right.

The game end when the second player place it's last piece on the top 
position of the pyramid. The winner is the player wich own the longuest
chain of simply connect pieces (not passing twice on the same piece).
This could be called the longuest simple path on the board.

Example in the following position:
Who win? X or O

             1- *
            2- * *
           3- * * *
          4- * * O *
         5- X * * O O
        6- X X O O O O
       7- X X X X O O *
      8- X X X X X O O O
          \ \ \ \ \ \ \ \
           A B C D E F G H

The longuest path of X is made of 12 pieces and 
the longuest path of O is made of 11 pieces, here is one best path for each:

             1- *                    1- *
            2- * *                  2- * *
           3- * * *                3- * * *
          4- * * O *              4- * * 1 *
         5- 1 * * O O            5- X * * 2 3
        6- 2 3 O O O O          6- X X1110 9 4
       7- 5 41011 O O *        7- X X X X 8 5 *
      8- 6 7 8 912 O O O      8- X X X X X 7 6 O
          \ \ \ \ \ \ \ \         \ \ \ \ \ \ \ \
           A B C D E F G H         A B C D E F G H

So in this position X win against O by 12 to 11.

USING PBeM:
I assume you are already a user of Richard's PBeM server,
so you just need to know the thing specific to this game.

When you use challenge to start a game, you can choose the default
board game of 8 pieces at the base with the following syntax:
	"Zenix challenge user1 user2"
Or with alternative board size using the -size=# option.
The valide size supported are -size=3, 8, 11 ou 12. Example:
	"Zenix challenge -size=3 user1 user2"
With the following result:
<<
Please start the game user1.

   Eks          Ohs       
   user1        user2     


        1- .
       2- . .
      3- . . .
          \ \ \
           A B C

       Own     Neutral  [Pieces lefts]
         2       1      Eks
         2       1      Ohs
>>

To play a move, you must specify the letter/number of the dropping location.
For example, first player (X) playing "Zenix move ### user1 pass1 B3",
will have the following result:

<<
        1- .
       2- . .
      3- . X .
          \ \ \
           A B C

       Own     Neutral  [Pieces lefts]
         1       1      Eks
         2       1      Ohs
>>

To play a neutral piece (rather than an own piece) you just need to
precede the board location with a '*'.
For example, if the second plater (O) playing "Zenix move ### user1 pass1 *A3",
it will have the following result:

<<
        1- .
       2- . .
      3- * X .
          \ \ \
           A B C

       Own     Neutral  [Pieces lefts]
         1       1      Eks
         2       0      Ohs
>>

Notice that the player 1 is winning if he play in B2. Indeed he will have
a longuest path of 2 pieces where 'O' will have two isolated pieces (=1).

IMPLEMENTATION:
This code is based on 'Game of Y' because it share the board same board shape.
However the logic of the game and detection of the winner is quiet unique.
There are two option to compile this code, with or without OPTIMISATION define
in 'zenix.h'.
By default the OPTIMISATION code is enable and can speedup the detection of the
winner in complex end possition. However, is some basic position is will
slow down a little bit that detection.
Make sure you test how much CPU time it take on the host computer to
detect who is the winner (only at the end of the game) and check if it is
acceptable. You can use my nine test games that are available as Perl script.

David GLAUDE (glu@who.net)

