Автор: Alyson Bailey
Год: 1982
Издатели: Sinclair User
Языки:
Формат:
Требования:
Ссылки:
Скриншоты:
Alyson Bailey takes her first steps with personal computers
Learning to program the Spectrum way
How clever are computers, I wondered, as I unpacked my
first, a Spectrum, two weeks ago. Since then my assessment
of this tiny box, no bigger than an average-sized book, has
varied through "very bright" to "doesn't think for itself"
and "shows great potential".
The manuals which accompanied the new toy were excellent
and we soon had a variety of combinations of BORDER and
PAPER flashing gaily on and off the TV screen, accompanied
by notes of random duration. A clock with a moving hand,
graphs and a design produced with circles of different dia-
meters followed in quick succession. If this was computing,
it was tremendous fun.
It was the youngest member of the family, aged 14, who
noticed the first deficiency. His friends, he said, had
computers which played games and ours did not. So far as we
knew, no software was available for the Spectrum and if we
wanted games we would have to type-in the programs our-
selves. Armed with a selection of computer magazines we set
to work enthusiastically but our enthusiasm soon began to
wane.
The print for some of the programs was too faint to read.
Others, though clearly printed, did not work. Our typing
errors did not help; the computer was amazingly fussy about
punctuation and that had never been one of our strong
points.
Although admitting that some of the failures were our
fault, others, we were convinced, were not. The computer
refused some words like RND(99) and other programs contain-
ing words like CHR and PEEK seemed doomed to failure. PLOT
resulted in miniature graphs in the bottom left-hand corner
of the screen.
What was wrong? Did the computer have a language and per-
haps even a dialect all of its own which prevented it com-
municating with even its closest relatives, the ZX-80 and
ZX-81? Was this ASCII - whatever ASCII is? At long last we
found a program which worked - *Luca* from /Sinclair User/,
June, 1982. Junior added sound and colour and altered the
graphics and what a difference those additions made. Who
complained that the sound was too quiet? Imagine all those
beeps played at the same volume as pop music.
Success was followed by more failures, despite avoiding
programs containing "foreign" words. Had we over-estimated
the powers of understanding of our computer yet again? We
studied the listings. Surely there were mistakes. Should
the letter in one program not be the number 5, the INT in
another be replaced by =; was CLS missing in another?
Several seemed to have whole lines missing while others
had superfluous ones, no doubt relics of bygone versions.
Our computer could not cope with typing errors. Those
errors were human and beyond the mental capacity of the
Spectrum. With errors corrected, those programs produced
several more working games. Why, we asked, do producers of
magazines over-estimate the ability of computers? Surely
experience should have taught them that computers are not
superhuman?
Frustrated by our failures but elated by our ever-
improving ability to understand our computer, we decided to
try to write our own program. We agreed that the concept of
our first attempt must be simple. /Sinclair User/ provided
the basic idea, the game *Nim.* It is a game for two play-
ers who take turns to take any number of matches, up to a
pre-determined value, from a pile of 100. The winner is
the person who takes the last match. We typed-in the basic
game:
100 LET j=100
150 PRINT j
200 INPUT a
300 LET j=j-a
400 PRINT j
500 GO TO 200
and decided to take up to 11 matches and set our program to
RUN. It worked. "That is a bit boring", commented junior,
and I must admit it fell far short of *Space Invaders.*
"Wait", I said, "it will get better". Colour impressed
him, so we added that - line 10 - and moved the numbers to
the centre of the screen - edit lines 150 and 400 - remem-
bering to clear one before the next appeared - line 390.
Running the program produced only a marginally better
response. We added captions, lines 15, 20, 22 - without
"one player and the" - 30, 32, 34, 36; some questions and
demands for answers - lines 40, 50, 60, 65, 70, 75 - let
the computer decide whose turn was next - lines 90, 170,
172 (without "AND bs <>"c""), 210, edit 500 and gave a
choice of number to be subtracted - lines 140, 145.
Then the game was much more interesting but cheating
began to rear its head and had to be eliminated - lines
240, 250. After much thought, I realised how to win and
decided to let the computer take my turn if so requested -
add the remainder of lines 22 and 172 and add lines 24, 67,
175, 190. We also added lines 450, 1000, 1010, 1020, 1030
to announce the winner. Interest soared.
It was at that point that the computer showed human
characteristics. It refused to play if it knew it could be
beaten. Addition of another line - 180 - forced it to
continue playing. Then it could not prevent me winning,
provided my mathematics did not let me down - and fre-
quently they did. Junior complained that the computer won
only because it had second turn. He was given the choice of
first or second turn - lines 72, 95 - but still he lost and
I won. No-one else has beaten the computer and if they do I
will alter the program so that even I cannot win.
All that leads me to wonder who really is my opponent
when I play games against a computer. Is the computer as
intelligent as it appears or am I playing some far-off
programmer I have never met?
Put this program into your computer and see if you can
beat it or me. If you can, try to alter the program to make
the computer win every time. If you succeed you are the
true winner. [All the more so because it's mathematically
impossible to do so - RLB] The computer can achieve no more
than the programmer - or can it? Are you as quick at mathe-
matics? I am not.
Learning to program the Spectrum way
How clever are computers, I wondered, as I unpacked my
first, a Spectrum, two weeks ago. Since then my assessment
of this tiny box, no bigger than an average-sized book, has
varied through "very bright" to "doesn't think for itself"
and "shows great potential".
The manuals which accompanied the new toy were excellent
and we soon had a variety of combinations of BORDER and
PAPER flashing gaily on and off the TV screen, accompanied
by notes of random duration. A clock with a moving hand,
graphs and a design produced with circles of different dia-
meters followed in quick succession. If this was computing,
it was tremendous fun.
It was the youngest member of the family, aged 14, who
noticed the first deficiency. His friends, he said, had
computers which played games and ours did not. So far as we
knew, no software was available for the Spectrum and if we
wanted games we would have to type-in the programs our-
selves. Armed with a selection of computer magazines we set
to work enthusiastically but our enthusiasm soon began to
wane.
The print for some of the programs was too faint to read.
Others, though clearly printed, did not work. Our typing
errors did not help; the computer was amazingly fussy about
punctuation and that had never been one of our strong
points.
Although admitting that some of the failures were our
fault, others, we were convinced, were not. The computer
refused some words like RND(99) and other programs contain-
ing words like CHR and PEEK seemed doomed to failure. PLOT
resulted in miniature graphs in the bottom left-hand corner
of the screen.
What was wrong? Did the computer have a language and per-
haps even a dialect all of its own which prevented it com-
municating with even its closest relatives, the ZX-80 and
ZX-81? Was this ASCII - whatever ASCII is? At long last we
found a program which worked - *Luca* from /Sinclair User/,
June, 1982. Junior added sound and colour and altered the
graphics and what a difference those additions made. Who
complained that the sound was too quiet? Imagine all those
beeps played at the same volume as pop music.
Success was followed by more failures, despite avoiding
programs containing "foreign" words. Had we over-estimated
the powers of understanding of our computer yet again? We
studied the listings. Surely there were mistakes. Should
the letter in one program not be the number 5, the INT in
another be replaced by =; was CLS missing in another?
Several seemed to have whole lines missing while others
had superfluous ones, no doubt relics of bygone versions.
Our computer could not cope with typing errors. Those
errors were human and beyond the mental capacity of the
Spectrum. With errors corrected, those programs produced
several more working games. Why, we asked, do producers of
magazines over-estimate the ability of computers? Surely
experience should have taught them that computers are not
superhuman?
Frustrated by our failures but elated by our ever-
improving ability to understand our computer, we decided to
try to write our own program. We agreed that the concept of
our first attempt must be simple. /Sinclair User/ provided
the basic idea, the game *Nim.* It is a game for two play-
ers who take turns to take any number of matches, up to a
pre-determined value, from a pile of 100. The winner is
the person who takes the last match. We typed-in the basic
game:
100 LET j=100
150 PRINT j
200 INPUT a
300 LET j=j-a
400 PRINT j
500 GO TO 200
and decided to take up to 11 matches and set our program to
RUN. It worked. "That is a bit boring", commented junior,
and I must admit it fell far short of *Space Invaders.*
"Wait", I said, "it will get better". Colour impressed
him, so we added that - line 10 - and moved the numbers to
the centre of the screen - edit lines 150 and 400 - remem-
bering to clear one before the next appeared - line 390.
Running the program produced only a marginally better
response. We added captions, lines 15, 20, 22 - without
"one player and the" - 30, 32, 34, 36; some questions and
demands for answers - lines 40, 50, 60, 65, 70, 75 - let
the computer decide whose turn was next - lines 90, 170,
172 (without "AND bs <>"c""), 210, edit 500 and gave a
choice of number to be subtracted - lines 140, 145.
Then the game was much more interesting but cheating
began to rear its head and had to be eliminated - lines
240, 250. After much thought, I realised how to win and
decided to let the computer take my turn if so requested -
add the remainder of lines 22 and 172 and add lines 24, 67,
175, 190. We also added lines 450, 1000, 1010, 1020, 1030
to announce the winner. Interest soared.
It was at that point that the computer showed human
characteristics. It refused to play if it knew it could be
beaten. Addition of another line - 180 - forced it to
continue playing. Then it could not prevent me winning,
provided my mathematics did not let me down - and fre-
quently they did. Junior complained that the computer won
only because it had second turn. He was given the choice of
first or second turn - lines 72, 95 - but still he lost and
I won. No-one else has beaten the computer and if they do I
will alter the program so that even I cannot win.
All that leads me to wonder who really is my opponent
when I play games against a computer. Is the computer as
intelligent as it appears or am I playing some far-off
programmer I have never met?
Put this program into your computer and see if you can
beat it or me. If you can, try to alter the program to make
the computer win every time. If you succeed you are the
true winner. [All the more so because it's mathematically
impossible to do so - RLB] The computer can achieve no more
than the programmer - or can it? Are you as quick at mathe-
matics? I am not.