Radio Shack TRS-80 PC-3 Owner's Manual page 190

Table of Contents

Advertisement

150: BEEP 2
160: PAUSE "DONE SORTING"
170: INPUT "DISPLAY OR PRINTER? "; A$
180: IF ( LEFT$ (A$,l)
=
"P") THEN PRINT
=
LPRINT
190: FOR 1= 1 TO N
200: PRINT S
(I)
210: NEXT I
220: PRINT
=
PRINT
230: END
Announce that sort is done
Ask where output should go
If printer is selected, set output to printer
Loop through sorted array
Print largest through smallest
Reset to original condition
Slot Machine Simulation
This program simulates the behavior of a simple slot machine. The model simulated is based on three wheels covered with pictures
of objects. One object from each wheel shows through the window at a time. In this simulation there are three objects which
alternate around each of the three wheels. On each play the wheels are spun and travel freely for a period of time. Then they begin
to slow down and gradually come to a stop. The stopping point of each wheel is random. If the same three objects show in all
three windows at the end of the play, then you win.
Notice that this program has been written so that it is easy for you to modify the number of objects, the speed of play, and the
combinations which produce a win. At the beginning, variables are set to control the speed during the spin (i.e., the amount of
time it takes for each new object to appear in the window). One controls the rate during the initial free-wheeling portion, and
another controls the rate during the slow down period. A third variable is used to control the length of other displays.
Another variable determines the number of objects to be used; Although only three have been used here, it is easy to change this
variable and provide more names in the data list, if you would like to try more. The amount of the win is calculated so that the
190

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents