GREEN-EYED MONSTER for Sinclair ZX-80
by P Connell
from Your Computer, October 1981

THE OBJECT of Othello is to place and win as many pieces as you can on an
eight-by-eight board. Once you have sandwiched your opponent, those pieces
then become yours, by changing to your colour. The game is over when the
playing board is full, the one with the most pieces is the winner.

On running the program, you will see the start pieces already on screen,
with the computer waiting for an input. Your colour is white, your
opponent, the ZX-80, plays black.

Having input your chosen co-ordinates, the screen blackens while the
computer checks that you have made a legal move, if not, then another input
is requested. The same applies if you accidentally input a co-ordinate
which is off the screen. Having accepted your move, the computer then
continues to calculate its own.

When the screen returns, it displays your move and automatically changes
any black pieces you have sandwiched to white. The screen then requests a
string input. Just hit the Newline key to display the computer's move. Then
it is your turn again. If you to stop the game at any time, input a letter
on your turn.

The computer's processing speed at the beginning of the game is a little
slow - as it has to loop the loop 59x8x8 times - but as the game
progresses, the off screen time is reduced. For those of you who wish to
change the game, the following list of variables may help.

First, loops: A helps print the screen then controls which direction, one
of eight, the computer scans; G counts the depth of search along a
particular line; K pokes the loop.

Secondly, variables: C is input; D means playing piece at any one time; E
is the opponent's piece at any one time; F is the number of bytes from the
corner of the screen to the position being played; H is the playing piece
at address being Peeked; I/J are the address of top left-hand corner of
screen; L counts number of potential wins from one position; N allows Poke
loop to be by-passed while the computer is scanning for its best move; Q
stores the highest number of potential wins from all positions scanned; R
checks if there are any more spaces left to play; V is the number of bytes
from the corner of the screen to the computer's best position to play; X is
for scan direction - with loop A; Z means if input "C" is an illegal move,
it returns for another input.

Thirdly, sub-routines: In Line 20, there is a space after the "8"; 400
checks if the positions scanned are better than previous positions scanned;
500 means if the new position is better than previous positions scanned
store the position and number of potential wins; 600 makes sure that move
is legal - if it is, then go to 700.

Line 700 is the Poke routine; 800 is the screen address; 900 increments
"L". Also, it provides the bias for the computer, i.e., to be biased
towards the diagonals on a random basis as the corners of the playing board
are the strongest positions to play from.
