							-*- text -*-
			      Natch 2.4
			      ---------


This is Natch 2.4, a program to solve chess proof games.

The input of Natch is a text file containing a position in the
Forsythe notation and a number of single moves.  Natch searches all
proof games leading to the position in exactly the specified number of
moves.

The input and output can be in any of the following languages:
english, french or german.

It has no graphical user interface (see iNatch software for that) but
can show what it does in a text window.


Installation
------------
To install the software, follow the generic instructions from the file
INSTALL.  If you don't want Natch to be installed in the bin
directory, don't use the `make install' command.  You can copy by hand
the generated executable from the src directory to the one of your
choice.

If you give the option `--enable-chloe' when executing the `configure'
script, Natch will be compiled with the possibility to read files in
the Chloe format (with the `.chl' extension) in addition to the
forsythe text format.  This is only useful in a DOS/Windows
environment, sole system where Chloe works.

You may have to edit the Makefiles to remove the characters `^M' at
the end of each line.


Compilation flags
-----------------
The default compilation options are for a release version : `-DNDEBUG
-O3'.  If you are interested by a debug version, change the CFLAGS
variable in the Makefile in the src directory to `-g'.


Compilation warnings
--------------------
If your system doesn't have the ncurses library but the curses library
(which is automatically detected by configure), you may have some
warnings.

If your system doesn't have getopt_long and replaces it by the files
getopt.c and getopt1.c (that's also automatically done by configure),
you may have 2 warnings for the compilation of getopt.c (about strncmp
and indfound).


Tests
-----
All the tests should pass without any problems in a few minutes
(depending on the speed of your machine).


Source files
------------
A great part of the software has been developed in the DOS/Windows
environment.  Some files thus may have DOS style line endings
(CR+LF) which translates to the presence of the `^M' at the end of the
lines.  But this should have no influence.


Running Natch
-------------

Here is the result of `Natch --help', showing the possible options.

Natch 2.4

Purpose:
  This program solves chess proof games.

Usage: Natch [OPTIONS]... [FILES]...

  -h, --help            Print help and exit
  -V, --version         Print version and exit
  -b, --beep            Beep at the end of the resolution  (default=on)
  -c, --continue=N      Continue resolution at position N
  -e, --explore         Explore moves  (default=on)
  -f, --verbose         Show progress on standard output  (default=off)
  -k, --watch=STRING    Watch occupied squares. See documentation
  -l, --language=CHAR   Language of output.  CHAR is `d' or `g' for Deutsch, 
                          `e' for English or `f' for Franais
  -m, --moves=N         Find all solutions in N single moves
  -o, --output=FILE     Output informations to FILE
  -p, --position[=LEVEL]Show positions.  LEVEL is 1 for positions, 2 for 
                          positions and moves order.  Without LEVEL, 1 is 
                          assumed.
  -s, --stop=N          Stop resolution after N solutions
  -t, --hash-size=N     Use N Mb for hash-table size  (default=`6')
  -v, --visual          Visual mode  (default=off)

Maintained by Pascal Wassong <pascal.wassong@free.fr>
Report bugs to <Natch@free.fr>


The first important option is `--hash-size'.  Use the highest value,
depending on the memory of your computer, so that it doesn't use the
disk for swapping.  A value of `32', for example, means use 32
megabytes of memory for hash-tables.  You must of course keep a part
of your RAM memory for the system and the program.

A common use is :

Natch -t 32 -l e -v -o solution.txt problem.txt

or using long option names :

Natch --hash-size 32 --language e --visual --output solution.txt problem.txt

The input file must contain a position in the forsythe notation, see
the file example.txt.  On DOS, it may also be a file in the Chloe format.

Using the `--moves' option overrides the number of moves given in the
input file.

Option `--verbose' is superseded by the `--visual' option.  But it
works even with the `--output' option.  This option may replace the
`--visual' option on system where the visual option doesn't work.

Option `--position' works even with `--output' option, where it is in
fact very useful.

Options `--beep', `--explore', `--verbose', `--position' et `--visual'
switch from the active to the inactive state and vice versa at each
use of the option on the same command line.


The NATCH variable
------------------

You may set the NATCH variable to your default options.  Example :

	set NATCH=--hash-size 32 --language e --visual


The `--watch' option
--------------------

The usual way to use this option is for example : --watch 4,e5,d6.
This means that for the first 4 single moves of the resolution, if the
squares e5 or d6 are occupied by the man which is there in the
diagram, then this square is considered as an obstacle for the other
men on the board if they have less than 2 spare moves.  The character
separating different suboption (`,' in the above example) may be
anything from the following set `.,;:/+-'.

This option takes a lot of computer time.  This is why it is
impossible to increase too much the numerical value.  You should use
this option if one side has a lot of spare moves.  If both sides have
no spare moves, this option takes more time than it saves.  But
determining the best numerical value is very dependent from the
problem and it is impossible to give default value.

The squares to watch for are in general easy to guess.  They are the
squares that should not be occupied to soon by the men in the diagram.

Here is an example :

Michel Caillaud and Markus Ott
feenschach, 1982
dedicated to K. Widlert, 2nd prize
r2qn1n1/2p5/3p1p2/rp2pp2/kb6/1P6/P2PPPPP/1bB1Kn1R
49 single moves

This problem is reproduced in the book by Wilts and Frolkin "Shortest
Proof Games" with the number 58.

We will only use the position resulting after the first 37 single
moves :
r1bqn1n1/1pp2ppN/3p4/rk2p3/1b2K3/8/PP1PPPPP/1RB2n1R
37 single moves

Without any `--watch' option, the problem is solved in about 1h 50 on
a Pentium 166 Mhz computer with 32 Mb of RAM.  With the option
`--watch 4,e5,d6', the resolution take approximately 3 mn (on the same
computer).

d7-d6 cannot be played before Bf8-b4.  The pawn allows a lot of black
moves (Ke8-d7-c6... and Nb8-d7-f6-e8).  By verifying that this move
isn't played to early, the number of moves that black can play is
restricted.

e7-e5 can only be played after Rh8-h5-a5.  The pawn only allows one
direct black move : Bf8-d4.  But white must play a big number of moves
before allowing the Rh8 to play, and thus white must have played these
moves before allowing e7-e5 and so only restricts the number of moves
that can be played.

But there is no good explanation for the `--watch 4' option.
Experience showed that `--watch 2' is insufficient and that `--watch
6' is unnecessary.  Use the visual mode with the <SPACE> key to see
the moves that obstruct and see until what number of single moves they
slow down the resolution.

The complete solution of this problem is :

1.Ng1-f3 Pa7-a5 2.Nf3-d4 Pa5-a4 3.Nd4-b3 Pa4xb3 4.Nb1-c3 Pb3xc2
5.Nc3-e4 Pc2xd1=N 6.Ne4-g5 Nd1-e3 7.Ng5xh7 Ne3xf1 8.Nh7-g5 Rh8-h5
9.Ng5-h7 Rh5-a5 10.Ke1-d1 Pe7-e5 11.Kd1-c2 Bf8-b4 12.Kc2-d3 Pd7-d6
13.Kd3-e4 Nb8-d7 14.Ke4-f5 Nd7-f6 15.Kf5-g5 Ke8-d7 16.Ra1-b1 Nf6-e8
17.Kg5-g4 Kd7-c6 18.Kg4-f3 Kc6-b5 19.Kf3-e4 Kb5-a4 20.Ke4-d3 Pb7-b5
21.Kd3-c2 Bc8-f5 22.Kc2-d1 Bf5xb1 23.Kd1-e1 Pf7-f5 24.Nh7-f6 Pg7xf6
25.Pb2-b3


Interruption
------------

The program may always be interrupted abruptly by `Ctrl + C'.

In visual mode, any key (except 's' and <SPACE>) is a better way to
interrupt the program. The 's' is used to skip the current position.


The `--position' option
-----------------------

When using the level 2 for the `--position' option, you get more
information about moves order.  Here is a short explanation which
should help you to understand that data.

Suppose we have : Ra1-h1-h7(2) in the position information and
Rh1-h7(14,1,L) among the moves order.

The first number (here : 14) is just a number identifying the piece
uniquely.  Both white rook could play Rh1-h7, so the number allows to
distinguish them.

The second number (here : 1) is the destination number.  Ra1-h1-h7 has
2 destinations.  0 is for the first (here : Ra1-h1), 1 is for the
second (here : Rh1-h7), etc...

The letter may be one of :
        - L for Last
        - F for First
        - B for Both

`L' means the last part of the move, this is when the piece arrives at
the destination.
`F' means the first part of the move, this means when the piece leaves
its square.
`B' means the complete move, this is Last and First combined.

For example Ph7xg6(39,0,B) -> Rh1-h7(14,1,L) means that the bPh7 must
have *left* h7 *and* reached g6 before the rook *reaches* h7.

A pawn capture is always a `B', as the move cannot be decomposed.  If
they are no spare moves, some pieces may also have a `B' for some
moves.

But if white has spare moves, it is possible that the wR plays for
example Rh1-h3-h7, and thus it is not possible to impose :
Ph7xg6(39,0,B) -> Rh1-h7(14,1,F) (with a `F' here).


Limitations
-----------

Here are given some of the known limitations and problems :

   * Only the solution in the given number of single moves are found.
   * Shown resolution times may be wrong when they are too huge.
   * When a rook must castle, it never checks the opposing king
     horizontally.  This would allow e.g. the black King to use the
     g1 square while white hasn't done the king side castling.  The
     only risk is to find illegal solutions.


Web
---

Natch has a page on the web from where the latest source files and
executables may be downloaded.  See:

	http://Natch.free.fr/

Mail suggestions and bug reports to Natch@free.fr.
