"The One Liner Challenge" (from Vol. 1 No. 6) I have been fascinated with "one-liners" for years. Ibought my first microcomputer (a 4K Model I TRS-80) almostseven years ago -- with only 4K, I couldn't write much morethan one line programs! Since then, I have owned a ModelIII, a TI-99/4A, a Color Computer, an MC-10 (does anybodyremember the MC-10?), and finally a Tandy 1000. Through theyears, with all those models, I have written quite a fewprograms, many of which have pushed the upper limits ofmemory. But some of my most challenging and interestingefforts have come in trying to squeeze an entertainingprogramming idea into only one line of BASIC. Not only doyou delight in hearing others comments about "how did youpossibly get all that stuff in one line", but you also endup learning a number of BASIC programming tricks. The official rules of the "one-line challenge" are quitesimple -- you must write an interesting, useful, orentertaining program using one and only one line of BASICcode. You cannot pre-initialize variables before runningthe program. The program may require some instructions foroperation (which can be held elsewhere), but should requirethat the user simply type "RUN" to make it go. If you wouldlike to try the one-liners found in this article, simplyenter BASIC (by typing the word "BASIC" at the A> prompt),type the line exactly as shown, read the accompanyinginstructions, then type "RUN" to begin program execution. Here are some of my most recent efforts. The first program,shown below, is called "Rocket Dodge". You are the pilot ofa futuristic rocket ship that is trying to weave its waythrough an asteroid belt. Use the comma and period keys tomove your ship (shown as the down-arrow character) to theleft and right, respectively. You must avoid collisionswith the asteroids that block your path, and you must alsostay within the narrow radiation bands that restrict yourmovement on either side. Your score is shown to the rightof the screen. 10 CLS:FOR A=1 TO 9999:A$=INKEY$:B=(A$=",")-(A$="."):C=B+D+30:LOCATE 10,C:E=SCREEN(10,C):IF E=25 OR E=32 THEN PRINT CHR$(25);:LOCATE 24,15:PRINT CHR$(176);TAB(16+RND(1)*31);CHR$(15);TAB(48);CHR$(176),A:D=B+D:NEXT ELSE COLOR 23:PRINT"X";:COLOR 7:LOCATE 23 This next program, which I call "Road Race", extends theidea of avoiding collisions on a scrolling screen. It isnot as complex as "Rocket Dodge", but it does include soundeffects and a little flash of color. Once again, use thecomma and period keys to keep your auto (shown as an "X") onthe winding, blue-brick road. As you move down the road,you will hear your the motor putt-putt-putt along. The gameends as soon as you leave the road; at that time, you willhear your car crash and see your final score displayed. 10 CLS:C=40:R=35:FOR S=1 TO 999:R=R+INT(RND(1)*3)-(R=1)+(R=69)-1:LOCATE 24,R:COLOR,1:PRINT SPC(10);:COLOR,0:PRINT:A$=INKEY$:C=C+(A$=",")-(A$="."):IF SCREEN(23,C,1)<>7 THEN LOCATE 23,C:PRINT"X";:SOUND 20000,1:NEXT ELSE NOISE 6,15,30:PRINT"Score:";S And now for something completely different, here is anothergame called "Depth Charge". In this game, your gunboat(represented as an "X") will cruise across the top of thescreen endlessly. You can watch it go across as many timesas you wish. You can drop a depth charge at any time bypressing the space bar. Try to place your depth chargebetween the brackets on the ocean floor shown like this: ] [If you hit one of the brackets, you get one point. Hit theempty space between the brackets and get two points. Youhave only ten depth charges, and the game ends when all tenhave been launched. 10 CLS:PRINT"Score =";S:LOCATE 22,39:PRINT"] [":FOR B=2 TO 79:LOCATE 3,B-1:PRINT" X";:IF INKEY$<>" "THEN FOR A=1 TO 8:NEXT A,B:GOTO 10 ELSE FOR A=4 TO 22:LOCATE A,B:PRINT".";:NEXT:S=S-SGN(ABS(B-40)-1)+1:BEEP:FOR B=1 TO 1000:NEXT B:C=C+1:IF C<10 THEN 10 Any musicians out there? The "Keyboard Organ" programtransforms you keyboard into a simple organ. Tap any key toget a note. The notes proceed in order from A below middleC up through several octaves in alphabetical order; type thealphabet to see what I mean. No keys are invalid; in fact,try the function keys for a nice surprise. 10 A$=INKEY$:IF A$="" THEN 10 ELSE A=(ASC(A$) AND 95) OR 64:B=A-INT(A/7)*7+63:PLAY "MF L16 O"+STR$(INT((A+3)/7)-8)+" "+CHR$(B-7*(B<65)):GOTO 10 No collection of one line programs would be complete withoutsome kind of geometric pattern program, and the following"String Art" program is just another of that ilk. Run thisprogram, sit back, and relax as you watch the hypnoticartistic patterns. The program will run infinitely. 10 SCREEN 1:COLOR RND(1)*8:CLS:A=100:FOR B=0 TO 100 STEP 5:A=A+(RND(1)>.5)*(A-INT(RND(1)*200)):C=200-A:LINE (B+60,100)-(C+60,C):LINE-(160,B):LINE-(A+60,C):LINE-(260-B,100):LINE-(A+60,A):LINE-(160,200-B):LINE-(C+60,A):LINE-(B+60,100):NEXT:GOTO 10 Finally, some people believe anything a computer tells them.Computers are incredibly smart, right? They must haveanswers for everything. This "Fortune Teller" program maynot be infallible, but it is lots of fun when several peopleare crowded around the keyboard waiting to see somethingamazing. Enter a yes-or-no question, let the computer thinkfor a few moments, then read the computer's sage advice(which you and I know is totally random). 10 DEF FNR(X)=INT(RND(1)*X+1):LINE INPUT"Enter yes or no question: ";Q$:CLS:FOR A=1 TO LEN(Q$):COLOR FNR(8):LOCATE FNR(24),FNR(80):PRINT"?";:SOUND FNR(999),3:NEXT:CLS:PRINT"Q: "Q$:PRINT"A: "MID$("Yes! No! Maybe I Dunno",FNR(4)*7-6,7):PRINT:GOTO 10 That's it for me; I have run out of one line program ideasthis month. But I am working on a couple of ideas. One ofthem, which I call "Zork IV" should be much easier than thefirst three editions; another called "Lotus 1-2" is acondensed version of another popular program. Usually, whenyou reach the end of a column on BASIC programming, theauthor closes by saying that there are no limits to what youaccomplish with BASIC. But with one line programs, thereobviously is a limit, and that is exactly what makes it somuch fun!