krieg.icn: Program to play kriegspiel

August 14, 1996; David J. Slate
This file is in the public domain.
Kriegspiel (German for "war game") implements a monitor and, if desired,
an automatic opponent for a variation of the game of chess which has the
same rules and goal as ordinary chess except that neither player sees
the other's moves or pieces.  Thus Kriegspiel combines the intricacies
and flavor of chess with additional elements of uncertainty, psychology,
subterfuge, etc., which characterize games of imperfect information such
as bridge or poker.
____________________________________________________________

The version of the game implemented here was learned by the author
informally many years ago.  There may be other variations, and perhaps
the rules are actually written down somewhere in some book of games.

The game is usually played in a room with three chess boards set up on
separate tables.  The players sit at the two end tables facing away from
each other.  A third participant, the "monitor", acts as a referee and
scorekeeper and keeps track of the actual game on the middle board,
which is also out of sight of either player.  Since each player knows
only his own moves, he can only guess the position of the enemy pieces,
so he may place and move these pieces on his board wherever he likes.

To start the game, the "White" player makes a move on his board.  If the
move is legal, the monitor plays it on his board and invites "Black" to
make his response.  If a move attempt is illegal (because it leaves the
king in check or tries to move through an enemy piece, etc.), the
monitor announces that fact to both players and the moving player must
try again until he finds a legal move.  Thus the game continues until it
ends by checkmate, draw, or agreement by the players.  Usually the
monitor keeps a record of the moves so that the players can play the
game over at its conclusion and see what actually happened, which is
often quite amusing.

With no additional information provided by the monitor, the game is very
difficult but, surprisingly, still playable, with viable tactical and
strategic ideas.  Usually, however, the monitor gives some minimal
feedback to both players about certain events.  The locations of
captures are announced as well as the directions from which checks on
the kings originate.

Even with the feedback about checks and captures, a newcomer to
Kriegspiel might still think that the players have so little information
that they could do little more than shuffle around randomly hoping to
accidentally capture enemy pieces or checkmate the enemy king.  But in
fact a skilled player can infer a lot about his opponent's position and
put together plans with a good chance of success.  Once he achieves a
substantial material and positional advantage, with proper technique he
can usually exploit it by mopping up the enemy pieces, promoting pawns,
and finally checkmating the enemy king as he would in an ordinary chess
game.  In the author's experience, a skilled Kriegspiel player will win
most games against a novice, even if both players are equally matched at
regular chess.
____________________________________________________________

The implementation:

The functions of this program are to replace the human monitor, whose
job is actually fairly difficult to do without mistakes, to permit the
players to play from widely separate locations, to produce a machine-
readable record of the game, and to provide, if desired, a computer
opponent for a single player to practice and spar with.

When two humans play, each logs in to the same computer from a separate
terminal and executes his own copy of the program.  This requires a
multi-tasking, multi-user operating system.  For various reasons, the
author chose to implement Kriegspiel under UNIX, using named pipes for
inter-process communication.  The program has been tested successfully
under Icon Version 7.5 on a DecStation 3100 running Ultrix (a Berkeley-
style UNIX) and also under Icon Version 7.0 on the ATT UNIX-PC and
another System V machine, but unanticipated problems could be
encountered by the installer on other computers.  An ambitious user may
be able to port the program to non-UNIX systems such as Vax-VMS.  It may
also be possible to implement Kriegspiel on a non-multi-tasking system
such as MS-DOS by using separate computers linked via serial port or
other network.  See the "init" procedure for much of the system-
dependent code for getting user name, setting up communication files,
etc.

Two prospective opponents should agree on who is to play "white", make
sure they know each other's names, and then execute Kriegspiel from
their respective terminals.  The program will prompt each player for his
name (which defaults to his user or login name), his piece color, the
name of his opponent, whether he wishes to play in "totally blind" mode
(no capture or check information - not recommended for beginners), and
the name of the log file on which the program will leave a record of the
game (the program supplies a default in /tmp).  Each program will set up
some communication files and wait for the opponent's to show up.  Once
communication is established, each player will be prompted for moves and
given information as appropriate.  The online "help" facility documents
various additional commands and responses.

A player who wants a computer opponent should select "auto" as his
opponent's name.  Play then proceeds as with a human opponent.  "Auto"
is currently not very strong, but probably requires more than novice
skill to defeat.
____________________________________________________________

Known bugs and limitations:

No bugs are currently known in the areas of legal move generation,
board position updating, checkmate detection, etc., but it is still
possible that there are a few.

Some cases of insufficient checkmating material on both sides are
not detected as draws by the program.

In the current implementation, a player may not play two
simultaneous games under the same user name with the same piece color.

If the program is terminated abnormally it may leave a communication
pipe file in /tmp.

Source code | Program Library Page | Icon Home Page