TELLING TIME IN PILOT
Easy educational program - only 104 linesby RICHARD SELTZER
This is a simple and well-documented program to teach children to tell time using three levels of difficulty. Best of all, it's only 104 lines long and runs on all Atari computers. Antic Disk subscribers simply LOAD D:TIME.PLT [RETURN]. Now type RUN.
In "Turtle Sketch Pad" in the December 1983 Antic, it was interesting
to see how to use PEEK and POKE-type commands in PILOT to get results similar
to programs written in BASIC.
But the real power and value of PILOT comes from its simplicity. Programs that stick to PILOT (without all the PEEKs and POKES) can be written and rejuggled right at the keyboard and can be understood at a glance.
In other words, for question and answer kinds of drills and exercises, teachers or parents can write programs in PILOT as easily as they might prepare worksheets or handouts. PILOT programs are a very do-it-yourself medium.
The following program illustrates the power and simplicity of PILOT with Turtle Graphics. I wrote it for my daughter Heather, age six, who wanted practice in telling time. It provides three levels of difficulty-hours alone, quarter hours, and five minute increments-all in just 104 short instructions.
PILOT's TURN and TURNTO commands, using the 360 degrees of a circle, are well suited to drawing lines radiating from a center point, like the hands of a clock. For instance, for the hour hand, we pick a random number from 0 to 11 (line 170), set 0 equal to 12 (line 180). Then (in line 200) we go to the center of the screen(0,0), and from the straight up position (TURNTO 0 in line 190) turn 30 degrees times the number of the hour and draw a line 15 units long (just a bit shorter than the minute hand, which we arbitrarily made 20 units long in line 190),
For the Quarter Hour version, we add an extra line (line 390) so the hour hand realistically moves ahead a quarter of 30 degrees (or 15/2) for each quarter hour beyond the hour. Similarly for the five minute version (line 590), the hour hand moves ahead a twelfth of 30 degrees (5/2) for each five minute increment beyond the hour.
Using the clock hands alone, without the numbers, made the games more interesting to play and also greatly simplified the programming.
#H=the hour, a random number from 0 to 11
#Q=the quarter hour, a random number from 0 to 3
#M=the five minute increment, a random number from 0 to 11
#N=the quarter or the five minute increment translated to minutes
#R=the number of questions answered right
#T=the number of questions asked (a game is 12 questions)
In the five minute version, if the correct answer was 5:05, with the standard format of #H:#M the program would expect an answer of 5:5. So in line 660, we add a match of #H:05, so the right answer is recognized as right. Also, when the answer is an exact hour, the natural inclination is to type just the number of the hour, without a colon and zeroes. Lines 460 and 670 make sure that that, too, will be accepted as a match.
Richard Seltzer is the author of two children's books, The Lizard of Oz and Now and Then and other Tales from Ome. He lives in West Roxbury, Mass.
10 T:WHAT'S YOUR NAME?
50 GR:PEN RED;GOTO 0,0;TURNTO #X;GO 25
110 T:DO YOU WANT TO PLAY HOURS (H), Q
UARTER HOURS (Q) OR FIVE MINUTES (M)?
(TYPE H,Q, OR M)
190 GR:GOTO 0,0;TURNTO 0;PEN YELLOW;DR
200 GR:GOTO 0,0;TURNTO #H*30;DRAW 15
210 GR:PEN RED;GOTO 0,0
230 T:WHAT TIME IS IT, $NAME? (JUST TY
PE THE HOUR)
270 TN:NO, IT'S REALLY #H. GOOD LUCK 0
N THE NEXT ONE, $NAME.
300 GR:GOTO 0,0;TURNTO #H*30;PEN ERASE
320 GR(#T=12):GOTO 0,0;TURNTO 0;PEN ER
390 GR:GOTO 0,0;TURNTO #H*30;TURN #Q*(
15/2);PEN YELLOW;DRAW 15
400 GR:GOTO 0,0;TURNTO #Q*90;DRAW 20
410 GR:PEN RED;GOTO 0,0
430 T:WHAT TIME IS IT, $NAME? (USE THE
FORM 9:15, 10:30, ETC.)
500 GR:GOTO 0,0;TURNTO #H*30;TURN #Q*(
15/2);PEN ERASE;DRAW 15
510 GR:GOTO 0,0;TURNTO #Q*90;DRAW 20
590 GR:GOTO 0,0;TURNTO #H*30;TURN #M*(
5/2);PEN YELLOW;DRAW 15
600 GR:GOTO 0,0;TURNTO #M*30;DRAW 20
610 GR:PEN RED;GOTO 0,0
630 T:WHAT TIME IS IT, $NAME? (USE THE
FORM 5:25, 12:05, ETC.)
710 GR:GOTO 0,0;TURNTO #H*30;TURN #M*(
5/2);PEN ERASE;DRAW 15
720 GR:GOTO 0,0;TURNTO #M*30;DRAW 20
890 T(#N=0):NO, IT'S #H:00. GOOD LUCK
ON THE NEXT ONE, $ NAME.
920 T(#N=5):NO, IT'S #H:05. GOOD LUCK
ON THE NEXT ONE, $NAME .
930 T(#N<>5):NO IT'S #H:#N. GOOD LUCK
ON THE NEXT ONE, $NAME.
970 T:VERY GOOD, $NAME. OUT OF 12, YOU
GOT #R RIGHT. WANT TO PLAY SOME MORE?
980 A :
1030 T:GOODBYE, $NAME.