LottoPik
- Type
- Utility
- Category
- Lottery number picker
- Author
- John Ferguson
- Published in
- Antic, November 1988 (Vol. 7, No. 7)
- Year
- 1988
- Language
- Atari BASIC
- Requirements
- Any Atari 8-bit, Atari BASIC; printer optional
- Tags
- antic, lottery, random-numbers, sorting, printer, beginner, atari-basic
About the program
By 1988 most US states ran a Lotto game, and Dr. John Ferguson, a marine-biology professor and starfish expert at Eckerd College in Florida, had noticed how hard people find it to choose their numbers. They play birthdays, ages, addresses and hunches. His argument in the November 1988 Antic was sensible. Every combination is equally likely to come up, but the prize is shared among everyone who picked it, so the best (if remote) chance is to choose numbers other people don't, and the way to dodge everyone's psychological biases is to pick purely at random, as the lottery itself does. LottoPik gets the Atari to do it.
Ferguson had written the earlier Beer Party Atari (Antic, May 1985). "I haven't won yet," he admitted, "but I have had my money's worth of fun."
Typing it in
It's short and plain. The one special line is 40, which underlines the heading with {CTRL-M} characters (hold CTRL and press M: the low horizontal bar). Before you run it, set X in line 5 to the highest number in your lottery. It's 49 as published.
How to use it
RUN it, and answer Y or N to "Do you want the results printed?". The screen fills with five lines of six numbers, enough for a playslip with five games. Press RETURN at "More?" for another five, or type N to quit. With printing on, each set also goes to the printer (P:), and if the printer doesn't answer, the program says so and asks again.
How it works
The article walked through the steps, and each takes only a few lines:
- Six different numbers. Line 70 picks
INT(RND(0)*X)+1. Lines 80–120 walk through the arrayB(), which was filled with −1 as "empty", and reject the number if it's already there. Otherwise it's stored in the first empty slot and the program goes back for another, until slot 5 is full. - Sorting. Lines 140–180 are a bubble sort: five passes of compare-and-swap over neighbouring pairs, which is plenty for six numbers.
- Neat columns. Line 210 turns each number into a string with
STR$and adds a leading zero to single digits, so every column lines up ("06", "09"). Line 220 builds the whole line inP$, so it can be sent to the screen and printer alike. - Margins.
POKE 82,6widens the left margin for the number display, andPOKE 82,2restores it.
Line 340 calls RND a random number of times before the first pick. The Atari doesn't need that, because RND reads POKEY's free-running random-number hardware, so there's no fixed sequence to escape from.
Variations to try
- Change
5in line 50 for more or fewer games per screen. - Add a "bonus ball" from a separate range after line 230.
Listing
1 REM LOTTOPIK
2 REM BY JOHN FERGUSON
3 REM (c)1988, ANTIC PUBLISHING
5 X=49:REM THE HIGHEST NUMBER IN YOUR STATE'S LOTTO
10 DIM B(6),Q$(3),P$(30),P1$(30),P2$(5)
20 GOTO 320
30 POKE 82,6:? CHR$(125):?
35 ? " LOTTO NUMBERS"
40 ? " {CTRL-M}{CTRL-M}{CTRL-M}{CTRL-M}{CTRL-M} {CTRL-M}{CTRL-M}{CTRL-M}{CTRL-M}{CTRL-M}{CTRL-M}{CTRL-M}"
50 FOR T=1 TO 5
60 FOR N=0 TO 5:B(N)=-1:NEXT N
70 A=INT(RND(0)*X)+1
80 FOR N=0 TO 5
90 IF A=B(N) THEN 70
100 IF B(N)=-1 THEN B(N)=A:GOTO 70
110 IF B(5)<>-1 THEN 130
120 NEXT N
130 ?
140 R=0
150 FOR N=0 TO 4
160 IF B(N)>B(N+1) THEN C=B(N):B(N)=B(N+1):B(N+1)=C
170 NEXT N
180 R=R+1:IF R<6 THEN 150
190 P$=" "
200 FOR N=0 TO 5
210 P1$=STR$(B(N)):IF LEN(P1$)=1 THEN P2$=P1$:P1$="0":P1$(2)=P2$
220 P$(LEN(P$)+1)=" ":P$(LEN(P$)+1)=P1$
230 NEXT N
240 ? :? P$
250 IF P=1 THEN ? #2,P$:? #2
260 NEXT T
270 ? :? :? "More";
280 IF P=1 THEN ? #2:? #2:? #2
290 INPUT Q$
300 IF Q$="N" OR Q$="NO" THEN POKE 82,2:? CHR$(125):END
310 GOTO 30
320 ? CHR$(125):? :? :POKE 82,2
325 ? " LOTTOPIK"
330 ? :? :? "Do you want the results printed?"
340 ? :? :INPUT Q$:FOR T=1 TO PEEK(20):P=RND(0):NEXT T
350 P=0:IF Q$="Y" OR Q$="YES" THEN P=1
360 TRAP 400
370 IF P=1 THEN CLOSE #2:OPEN #2,8,0,"P:"
380 IF P=1 THEN ? #2," LOTTO NUMBERS":? #2:? #2
390 GOTO 30
400 ? :? :? "PRINTER NOT RESPONDING!":? :? :GOTO 330
Download
The original program from the Antic disk, to LOAD or ENTER instead of typing it: LOTTOPIK.BAS.
Credits
- Program listing: LottoPik — program listing (Antic, November 1988 (Vol. 7, No. 7)) — John Ferguson
- Picture: One playslip's worth: five games of six numbers from 1 to 49. — John Ferguson (program); screenshot by the site
- ANTIC Vol. 7 No. 7 (November 1988) — LottoPik, by Dr. John Ferguson — John Ferguson, 1988
- Antic Software Archive — November 1988 - Vol. 7 No. 7 disk: LOTTOPIK.BAS — AtariMagazines.com (Kevin Savetz), 1988
