A List of Answers
Two answers aren't enough. Store eight in a string array, then use RND as an index to reach in and pull one out — one PRINT line that can speak any of them.
Two answers and the game gets old in a minute. The Oracle needs many replies — and a tidy way to hold them. That's an array: a numbered row of variables, all sharing one name.
10 PRINT CHR$(147)
20 DIM A$(8)
30 A$(1)="IT IS CERTAIN"
40 A$(2)="THE SIGNS POINT TO YES"
50 A$(3)="WITHOUT DOUBT"
60 A$(4)="ASK AGAIN LATER"
70 A$(5)="CANNOT FORESEE IT NOW"
80 A$(6)="DO NOT COUNT ON IT"
90 A$(7)="MY REPLY IS NO"
100 A$(8)="OUTLOOK NOT SO GOOD"
110 INPUT "SPEAK, MORTAL";Q$
120 R=INT(RND(1)*8)+1
130 PRINT
140 PRINT A$(R)
DIM A$(8) sets aside a row of eight string slots, named A$(1) through A$(8). Lines
30–100 fill them — one answer each. Then the choosing: R = INT(RND(1)*8)+1 rolls a number
from 1 to 8, and PRINT A$(R) uses it as an index — the number that says which slot
to read. One PRINT line, eight possible answers.
This is the same RND as last time, just scaled to 8 instead of 2 — and pointed at an array
instead of an ON…GOTO. Add a ninth answer and the only change is DIM A$(9) and *9. The
array grows; the choosing line doesn't.
Try this
- Write a funny one. Slip in an answer that makes people laugh — those are the ones they re-run for.
- More answers. Bump
DIM A$(12)and the*8to*12, then add four more replies. The Oracle gets deeper, the code barely changes.
What's next
The answer appears the instant you press RETURN — too fast for something wise. In Unit 4 the Oracle learns to think: a pause, a tone, and then the reply.