CRICKET (ZX-81) by Peter Horlock
from Sinclair User 9 (September 1982), page 62

Cricket and summer go together, so for the summer competition Sinclair User
asked for a cricket simulation program. The response was varied. Some people
designed programs with good graphics and otehres decided to concentrate more
on the laws of the game.

Mnay of the programs went some way to playing a good game of cricket but none
seemed to produce complete simulations. In some cases it was difficult to
tell whether the author of a program knew what a computer simulation was.

The simulation needed to be fairly logical in its approach to play. It needed
to cater for incorrect and ridiculous entries. None of the programs did that
sufficiently well, although the task is possible and there was no restriction
on memory size.

Several programs were reasonably close to a good simulation and the best of
them was a limited-overs game by Peter Horlock, of Godalming, Surrey.

His program simulated a game of two innings between Surrey and Middlesex,
each inning consisting of ten players. At the beginning of the game the
players are asked to choose sides and the toss is made to decide who bats.

The player whose team is fielding is shown a list of men in the team and may
chose a bowler from any of them, except the wicketkeeper, who is shown by an
"=". Alongside each player's name is his bowling form and the number of overs
he can bowl during the game.

When the bowling side is set up, the battling side will be listed by the
computer. The form of each batsman is also displayed. The computer will
choose the two batsmen who are to play next and ask the batting player to
enter their form, which is usually a number between one and 20.

When bowling and batting form have been entered, the computer will decide the
outcome of a delivery. The batsman could be run out, caught, or leg before.
The bowler could bowl a wide or one of the fielders could miss a catch.

Several times during the game the computer will ask whether the players want
an analysis of play so far. The batting of bowling figures can be obtained in
that way for both sides. The bowling table shows the number of overs,
maidens, runs, and wickets for each bowler. It will also show the name of the
present bowler, the number of overs so far playerd, and the number of
deliveries in the current over.

The batting analysis shows the names of the players who have batted, the
number of runs scored by each, and whether they are out. It also displays the
total runs obtained and the number of batsmen who have been dismissed.

When all the batsmen have been despatched, the teams are switched by the
computer. Each team has a maximum of 20 overs. The winner is displayed at the
end with a note of the winning margin.

The game is played using the form of the bowler and batsmen as the deciding
factor. The computer determines the chances of a batsman scoring runs or
being out with his present form and takes action accordingly.

Horlock needed a few weeks to write the game. He bought his ZX-81 in February
and uses it mainly for sports-orientated and intellectual programs. He says:

"I have a ZX-81 version of chess which interests me and I also have a
football pools prediction program. The football program takes into account
all four divisions of the league".

He is very interested in computers and writes many programs. He was
introduced to the ZX-81 last Christmas by a friend in the roofing department
of a local firm where he works. He is not a member of any local user group
but many of his workmates are also interested in Sinclair computers.

His reasons for entereing the competition were for pleasure and practical
necessity. He said: "The subject matter interested me and I decided to write
the program. The printer I bought with my ZX-81 broke down and I returned it
to Sinclair. In the meantime I thought I might be able to win another one in
the competition."

The limited-overs cricket program uses much less than 16K of memory. Horlock
has written an upgrade of the program which fills the remaining space. The
program allows one player to play a game against the computer.

[Note that there might be two typos in the game "Cricket". I could not make ]
[out the second inverse character on line 3507 (I went for inverse 'D' but  ]
[that was the only such instance of a 'D' so could very well be wrong). Line]
[9090 runs a subroutine but the line number is displayed corrupt, so I have ]
[guessed it to be 9500). The game seems to run OK but I might not have hit  ]
[those lines in testing and don't know all the rules of cricket so might not]
[spot 'obvious' mistakes caused by these 2 lines.                      PaulF]
