The title of this post is drawn from Jonathan Coulton’s project to write and publish a new song every week and post it on his web page. Which, I mean – holy crap. Talk about prodigious output… I’ll never approach that level of productivity, but it is incredibly inspiring, amirite? So inspiring in fact, that I’ve decided to dedicate myself to writing one Apple II or III program a week, for the next year. I don’t expect them to be complex or particularly interesting, just that they work and they are complete. I’ll post the results here as I work. I realize this isn’t the first time I’ve made a promise on this blog that I haven’t really tried to keep (*cough*Infocom*cough*) and I may not get far on this, but let’s not quit before we get started, shall we?
As I said, these programs won’t be particularly interesting or useful, mainly because my Applesoft BASIC skills are beyond rusty – they’ve mostly corroded to dust. I also intend to use this as an opportunity to follow through my threats to learn 6502 assembly language, as well as explore some Apple III programming opportunities. Likely, I’ll start with Business BASIC and move on to Pascal on that metal. In the spirit of focusing on the learning opportunity presented here, I’m hoping to include at least one technique or concept new to me in each program. And because I’m trying to cut back on making grandiose statements and announcements that lack any form of follow-through, here’s my first program, in Applesoft:
]LIST
5 A = 0:B = 0:C = 0
10 HOME
15 PR# 3
20 PRINT “THING A WEEK 1″
30 PRINT : PRINT “THE APPLE II VARIANT”
50 PRINT : PRINT “WHEREIN, WE PLAY A GUESSING GAME.”
60 PRINT : PRINT “I THINK OF A RANDOM NUMBER BETWEEN 0 AND 20, AND YOU TRY TO GUESS IT.”
70 PRINT : PRINT “THE GAME ENDS WHEN YOU GUESS CORRECTLY.”
90 PRINT : INPUT “PRESS ANY KEY TO BEGIN. “;A$
100 HOME
110 INPUT “ENTER A NUMBER BETWEEN 0 AND 20: “;A
120 IF A < 0 OR A > 20 THEN 500
130 B = INT (20 * RND (1))
140 C = C + 1
150 IF A = B THEN 200
160 : PRINT : PRINT “I WAS THINKING OF “;B;”, BUT YOU GUESSED “;A;”.”
170 PRINT “TRY AGAIN!”
180 PRINT : GOTO 110
199 END
200 HOME : PRINT “I WAS THINKING OF “;B;” AND YOU GUESSED “;A;”. YOU WIN!”
210 PRINT : PRINT “YOU GUESSED WHAT I WAS THINKING IN “;C;” TURNS.”
220 PRINT : INPUT “WANT TO PLAY AGAIN? (Y/N)”;B$
230 IF B$ = “Y” THEN GOTO 5
240 IF B$ = “N” THEN HOME : CLEAR : END
250 GOTO 220
400 END
500 PRINT : PRINT “PLEASE PICK A NUMBER BETWEEN 0 AND 20…”
510 INPUT “WE COULD DO MORE, BUT WE MIGHT BE HERE ALL AFTERNOON! “;A$
520 PRINT
530 GOTO 110
]
The game gets tedious in a hurry, the code isn’t pretty and there are probably a few bugs, but it seems to work. I tried to do this entirely from memory, without having to resort to any BASIC programming guides, but I admit I failed on this one. I was drawing a blank on using the INT function to trim the random numbers to whole numbers. Still, not a bad start I think.
It’s better than I could do from memory! One a week is both aggressive and reasonable. Don’t be afraid to claim a “library” as a “program” for this -especially if you use it in future applications. We’re rooting for you!
+1 with Wholly, hat off to you Mike!
Note that INT() is actually a truncate function. Your random number generator will actually yield numbers between 0 and 19.
130 B = INT (21 * RND (1))
will get you 0-20.
Now put those /// business basic books to good use – let’s see some Apple /// love!
Thanks for the tip, David! I knew there was something wrong about that. Just couldn’t put my finger on it.
A week at KansasFest will give me some time to play with Business BASIC. Maybe I’ll have something to post, Apple III related next week.