INTERCEPT (ZX-80)
by Ian Wright
from Sinclair User 1 (April 1982)

INTERCEPT, written for the ZX-80 by Ian Wright of Weybread, Diss, makes good
use of POKEing to the screen. The aim of the game is to destroy the enemy
missile  a less-than symbol  with your intercept missile (*) before the
Federation Freighter  an inverse plus sign  is destroyed.

If you succeed, the Freighter remains on the screen with the message
INTERCEPTED. If you do not, the missile hits and only the message DESTROYED
remains. The game is relatively simple if no mistakes are made.

The missile is launched from a different position each time. To make the game
more difficult, once you have mastered the version as listed you can delete
several lines, making, for example, D equal to 14 and FOR F=1 TO (527-66),
and allowing the enemy missile to move at random.

Then, of course, you have the problem of how to make it destroy the Freighter
each time, without writing more program than you can fit in 1K. You may well
like to tackle the problem. We would be interested in seeing what variations
on the game you produce.


= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =


STAR SWERVER (ZX-81)
by Tim Rogers
from Sinclair User 1 (April 1982)

Fourteen-year-old Time Rogers of Richmond, Surrey, provided us with this
splendid game, in which you have to steer your space ship - a minus sign
followed by a less-than symbol - past the stars which block your path as
you whizz across the little inverse universe which the 1K ZX-81 sets up
for you in SLOW mode.

Each time the computer creates the universe with stars, you have a chance
to see where they are placed, so that when your ship enters the universe at
a random height from the right, you will have some idea of where to steer
to avoid them.

Your score is given at the end of the game. Some weird thing happens, about
which I will not warn you, when you hit a star. Rogers writes about his
program:

"In this game I have used nearly every memory-saving technique I know,
including using PI-PI instead of 0 and PI/PI instead of 1.

"I have also used VAL "10" instead of just the number 10. I took the INKEY$
line from Mark Charlton's book 'The Gateway Guide to the ZX-81 and ZX-80'
and I think it is very clever. It works like this:

95 LET P=P+(INKEY$="6" OR P=P-PI)-(INKEY$="7" OR P=L).

The variable P is the position up the screen of the space ship, so that if
someone is pressing "6", the statement inside the brackets is true and this
returns a 1, which is added to P, and as it is false - i.e. "7" not being
pressed - 0 is returned and taken away from P".


= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =


SQUARE ROOT SOLVER (ZX-81)
by Tim Hartnell
from Sinclair User 1 (April 1982)

Square Root Solver will work out the square root of any number you enter.
It first guesses - line 80 - by picking any number between zero and the
number chosen. The computer then refines the guess by division, over and
over again, checking each time to see how close to the correct answer it is.

Line 120 is not part of the computer checking apparatus - which you can
verify by deleting the line - but is there so that you can watch the action
of the computer as it searches for the correct answer.

As the ZX-81 has SQR function, the program is of little practical use but
it is fascinating to run and watch how quickly it finds the correct answer.
In the two sample runs, the computer is looking for the square root of nine
- example one - and of two - example two.


Example 1 output:

WHICH NUMBER DO YOU WANT ME
TO FIND THE SQUARE ROOT OF?
5
ERROR IS 2
3.4
ERROR IS 0.4
3.0235294
ERROR IS .023529412
3.0000916
ERROR IS .000091554597
3
ERROR IS 1.8626452E-9
3
ERROR IS 0
3
ERROR IS 0

THE SQUARE ROOT IS 3


Example 2 output:

WHICH NUMBER DO YOU WANT ME
TO FIND THE SQUARE ROOT OF?
1.5
ERROR IS .085786437
1.4166667
ERROR IS .0024531037
1.4142157
ERROR IS 2.1234155E-6
1.4142136
ERROR IS 4.6566129E-10
1.4142136
ERROR IS 4.6566129E-10

THE SQUARE ROOT IS 1.4142136


= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =


GRAPH PLOTTER (ZX-81)
by R Easto
from Sinclair User 1 (April 1982)

This program, which is fascinating to run, was written for a 1K ZX-81 by
R Easto of Reigate, Surrey. He describes it as follows:

"The program plots the graph of any curve entered in the form 'X*X-2+4*X'
or even '1/X'. Line 130 is the heart of the program, where the VAL command
puts Y equal to the values of X required by your formula (entered in line
100). The program allows more than one curve to be viewed at once."

The three sample curves plotted are X*X, X*X+4*X*X and 39/X. Do not use
shift H key (**) for powers of X as an error will result.


= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =


OTHELLO
by Graham D Charlton & Tim Hartnell
from Sinclair User 1 (April 1982)

Othello is based on the game Reversi, which was invented in 1888. Reversi
was played on a standard draughts board, using pieces which were double-
sides, black on one side, red on the other. R.C. Bell explains, in his
book Discovering Old Board Games, Shire Publications Ltd, Aylesbury, 1980,
that black begins the game by placing a piece black side up on one of the
four central squares on the empty board.

Red replies by placing his first piece red side up on another central
square. "The four squares are covered in the first four turns of play and
then the players continue alternately, placing their pieces on a square
adjacent to one occupied by an enemy piece", says Bell.

Any enemy pieces in a straight line between the latest piece placed and
another one of the player's pieces is then flipped over to show the colour
of the player. The winner is the player with the most pieces when the
board is covered, or when neither player may move.

A member of the National ZX-80 and ZX-81 Users' Club, G.J. Suggett, of
Chichester, Sussex point out, when discussing computer Othello, which is
simply Reversi with a restriction on the opening position:

"Most published Othello programs evaluate the best move for the computer
to make on the basis of maximising the number of captures made with a
possible extra score given to certain positions, such as the corners.
In fact, in the early stages of the game, positional play is far more
important than making a large number of captures."

This program, by Graham Charlton and Tim Hartnell, lends more weight to
position than to the number of pieces available to convert. When you press
RUN, you will see the board appear with the four first pieces in place.
You enter a move by entering the number down the left-hand edge of the
board next to the square where you want to move, then the number across
the board of that square. Enter those numbers as a single number, such as
36, then press NEWLINE. Enter zero if you are unable to make a move.

Once you have played a few games with the program, you might like to alter
its strategy slightly by changing the 2 in lines 1220, 1230, 1240, 1250,
1260 and 1270 into 3 or even try deleting the lines completely, perhaps by
adding 1215 GOTO 1280. [This is bollocks, as there are no such line
numbers in the listing. JimG]

The name Othello is copyright Mine of Information, which sells a sophis-
ticated ZX-81 machine code program under that name. A 1K version of the
game, also in machine code, is available from Logan Software.


= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =


BLACKJACK (ZX-81)
by Tim Hartnell
from Sinclair User 1 (April 1982)

The card game Blackjack is very popular. In his book "Beat the Odds,
Micrcomputer Simulations of Casino Games" - Hayden, 1980 - Hans Sagan says it
is "probably the most popular and most widely-played banking card game in the
States. It is played in gambling houses, private clubs, political clubrooms,
barracks, troop transports, back rooms of all kinds, and places you may never
have heard of".

John Scarne, in his authorative "Scarne's Encyclopedia of Games", agrees:
"Blackjack is the most widely-played banking card in the world".

Sagan says Blackjack is "the one casino game where the player may have a
chance". Part of the chance is based on the fact that the cards removed from
a pack as the game is played change the odds of other cards appearing - and
knowing the odds can be of some benefit in deciding what to do. The player
advantage is stymied in this version because the ZX-81 has somehow acquired
an infinite, constantly-replenished pack of cards.

Despite that, the computer plays reasonably well and will certainly give you
a run for your money. There is no direct betting in the game and that is a
feature you may well want to add in due course. You may also like to change
the program so that it goes through a pack of cards before there is a need to
re-shuffle. You can store the pack in a REM statement or in an array.

Blackjack is not difficult to play. You and the computer add the total of the
cards you hold, trying to go as close as possible to 21, without exceeding
21. Aces count as either one or 11, and kings, queens and jacks each count as
10. The program assigns a value of one automatically to an ace if counting it
as 11 would force the total above 21.

The computer deals two cards to the human and one to itself. You have the
option of taking another card at any time during your turn, or sticking -
that is, staying with the cards you hold.

The round is a draw if both reach the same total less than 21. If you bust -
exceed 21 - the deal (ZX-81) wins the round automatically. You need around
2.5K for the game.

Note the use of the word End in line 140. That is not a mistake and it stops
the program because the computer 'reads' the word END as unassigned variable
and stops the program with an error message.


= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =


OLD FORTY-NINER
by Tim Hartnell
from Sinclair User 1 (April 1982)

This game is somewhat like draughts, except that it is played on a 7x7
board, hence the name Old Forty-niner. The pieces move as draughts
pieces - diagonally one square, jumping over an opponent for a capture
into an empty square beyond the opponent. The main differences from
draughts, apart from the size of the board, are that pieces may move
forward and backward at will, there are no kings - every piece can move
as if it is a king - and there are no multiple jumps.

The computer is the Xs moving down the screen and you are the Os. You
move by entering the number of the square from which you are moving -
entering the number along the left-hand edge first, then the number
across the top, then pressing NEWLINE - then the number of the square to
which you are moving.

The ZX-81 keeps track of the score, tells you before it moves its pieces
to which square it is moving, and terminates the game as soon as one
player manages to capture five of the opponent's pieces.

The program, which needs about 3.5K, was written by Tim Hartnell and
shows some structured programming techniques. Line 30 sends the action
to a subroutine at the end of the program which initialises the
variables. The computer then goes to its move routine, starting at 7000.

Having made a move, it returns to line 50, enters the SLOW mode and goes
to the subroutine at line 8000 to print out the board. From there it
goes to subroutine 6000 to accept the player's move, to 8000 to reprint
the board, into FAST (line 100) then back to make the computer's next
move, and so on.

The advantage of working in that way, with a specific subroutine for
each section of a program, is that you can easily alter part of the
program which appears unsatisfactory without facing the danger of
running out of lines, or of getting lost. Placing variables assignment
at the end has the advantage that you can add new ones, as the need for
them becomes apparent, without problems. The layout of the program is
simple:

1-1000     Main loop; sends action to various subroutines.
6000-6990  Accepts player's move; updates score for player.
7000-7470  Makes computer's move; updates ZX-81 score.
8000-8990  Prints out board [and] score; checks if game is over.
9000-9140  Assigns variables.

Although this is not the most memory efficient method of programming, it
makes the work of debugging and future development of a program much
easier.

If you would like to learn about structured and top-down programming,
you could do well to read Basic With Style by Paul A Nagin and Henry F
Ledgard, published by the Hayden Book Co Inc.


= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =


--
Another Fine Product transcribed by:
Jim Grimwood, Weardale, England (http://www.users.globalnet.co.uk/~jimg/)
--