Cross The River - Chris Howard Stone (ZX Computing-Aug/Sep 84)


One day, a farmer was carrying a bag of corn home,
accompanied by a hen and a wolf, when he came to a river. After a
while the farmer found he could wade across the river carrying
either the corn bag, the hen or the wolf. He then realised that if
the hen and the corn were left together without his supervision,
the hen would eat the corn. He also realised that if the
wolf and hen were left unsupervised, the wolf would eat the
hen. How did the farmer solve his problem?
	The farmer can be made to carry one article across the river
by pressing W (to transfer the wolf), H (to transfer the hen) or
C (to transfer the corn bag). Remember that an article can
only be transferred across the river if it is on the same bank as
the farmer.

THE PROGRAM
Each graphic representation (farmer, corn bag, hen, wolf) is
made up of four user-defined graphics characters. The procedure
for defining these characters consists of lines 10 to 332.
Lines 400 to 450 draw the bank and the river. Each
character is given a numerical variable which is either 1 or -1
according to which bank they are on. This variable is then used
to print the characters on the appropriate side of the bank.
	The subroutine beginning at line 1000 ensures that any
mistakes (e.g. wolf eats hen) are spotted and acts accordingly. If
a mistake has been made, the player is informed and the game
starts again. Line 1000 checks to see whether the puzzle has
been successfully completed and, if this is the case, prints a
message of congratulation. Line 520 gets a key-press from the
keyboard and checks to see if it is either H, C, W or F (upper or
lower case). No other input is permitted. Having verified that
the key-press is O.K., lines 545 to 557 check whether the move
is O.K. No illegal moves (e.g. pressing H when farmer and hen
are on opposite banks) are allowed. Assuming all is well,
lines 580 to 620 erase the present image of the characters to
be moved, and also that of the farmer as he is always moved
from bank to bank whether he carried something with him or
not. When a character crosses the river, its assigned variable
changes sign and this is accomplished via lines 630 and
550 to 570.


[What an incredibly tedious UDG setup routine!   ]
[About ten times as long as it needs to be. JimG ]

------------------------------------------------------------------------------
TYPE: Thinker 

Comment:

This info file was typed by Jim Grimwood

Downloaded from:
Desert Island Disks -- http://www.image.dk/~frankie/
Maintained by:
Michael Bruhn -- frankie@image.dk
