ANTIC v2.06 / SEPTEMBER 1983 / PAGE 28
The buzzword to cope with in the classroom these days is no longer “computer,” it’s “Logo.” If your computer doesn’t have Logo you can forget the educational market. Atari has taken heed and marched in with its version of Logo, built into a 16K cartridge, ready for school this year.
Logo is a versatile computer language designed to ease exploration and discovery of computer functions and power. It is easy enough for children to use, yet complex enough to permit very advanced work by expert programmers. It sidesteps the cumbersome rituals of BASIC — its most serious competitor in the classroom.
Based on LISP, the most powerful of the artificial intelligence languages, Logo has been in development for about ten years, principally by Seymour Papert at MIT, and by Logo Computer Systems, Inc. of Quebec, Canada. The development of Logo is a story we won’t go into. Suffice it to say that most of the popular micro computers have a version of Logo, some of them several versions. Atari Logo, from Atari, Inc., is the first for ATARI computers, and though it is a latecomer, it is a good one. It runs on all ATARI computers (even the 400 with 16K RAM) and sells for $99.95.
Atari Logo gives the user extraordinary power to manipulate and create lists of words. A simple yet elegant turtle graphics system allows even novice programmers to create microworlds and explore them. Imagine a BASIC which would allow you to create new commands — Logo does just that!
So why Logo, anyway? Simply put, Logo is the language of learning. It is designed to be easy to begin. Like PILOT, a few simple graphics commands move a “turtle” around the screen to create beautiful designs; a few text manipulation commands allow construction of sophisticated question-and-answer quizzes or games. In brief, Logo has a low threshold.
But, like the piano which can be played at a simple level, while also serving as the instrument of Liszt, Logo has no ceiling. The individual author creates new commands (called “procedures”) and incorporates them in later programs as naturally as a boy puts stones in his pocket. Let’s illustrate this latter feature with a simple example. Logo does not include an “absolute” command — one which converts negative numbers to their positive values. If you needed this often, you would teach Logo how “to absolute” as follows:
TO ABSOLUTE :NUMBER OUTPUT IF :NUMBER <0[- :NUMBER] [NUMBER]
As defined above, the procedure ABSOLUTE will take any number and if that number is less than 0, output the negative of the number (a negative of a negative is a positive, so one gets a positive number). If the number is greater than 0, it outputs the number (which is already positive).
Using our new command is simplicity itself. For instance “PRINT ABSOLUTE - 3” prints a “3.” Later, the command could be used in any new programs just as simply. There is no need to recode the command, change line numbers or use complicated GOTOs or PERFORMS.
Logo is often self-documenting; i.e., it is easy to read compared to BASIC or other less structured languages. In Logo, a problem is automatically written as a series of small procedures which talk to one another in a simple, direct way to produce the overall output.
Yet, unlike PASCAL and the similar “structured” languages, Logo is interactive — you can instruct it to do something and immediately see the results without compiling programs, etc. This makes it easy to write and debug programs.
Logo’s design welcomes experimentation. Throughout, the word “error” is not used. For instance, if the command ABSOLUTE had not been defined, and you issued the command ABSOLUTE - 5, Logo would respond with “I don’t know how to absolute.” Other messages are similarly positive — “You don’t say what to do with…,” “PRINT doesn’t like XXXX as input” or “file XXXX not found.” (Boy, won’t you miss the old “ERROR 170”!)
As a friendly language with virtually no prerequisites (anyone can do interesting things right away) and no limits (no one gets bored), Logo has found a natural home in schools. It deserves a similar place in home computing. It, and PILOT, are critical tools to teach more than programming — they develop logical thinking.
Let’s turn to Atari’s Logo. Programmed permanently into one of those nearly indestructible cartridges, Atari Logo appears much more durable than the disk-based versions for Apple or the Commodore 64. Atari Logo can operate completely effectively with a cassette-based system and as little as 16K of memory (TI Logo needs 48K RAM). As a result, an Atari start-up package is much cheaper than virtually any other Logo system.
As I prepared this article, I poured through material on three versions of Logo for Apple, one for the TRS Color Computer and one for the Texas Instruments TI 99/4A. Without exception, the Atari product offers advantages over each of these products.
That’s a pretty strong statement, yet I feel it’s easily supported. Simply put, Atari Logo benefits from being late on the scene and thus incorporates advanced features. It builds on the superior sound, graphics and keyboard capabilities of the 800/400 systems (compared to alternative machines).
Logo in general offers two outstanding programming features — turtle graphics and list processing. Although graphics are undoubtedly the initial exposure for most people, the language’s true power becomes apparent with the extensive set of commands to control lists of words (sentences) in a learning environment. The Color Computer’s Logo does not even have list-processing capabilities. It’s a bit like a BASIC with numeric computing but no graphics. In the old days (say, 1979), people tolerated that limitation; they don’t have to anymore, and neither should today’s Logo user. To be fair, the Color Computer’s multiple turtles represent an extremely nice implementation of turtle graphics, but it is only half a language, in my opinion.
TI’s Logo offers an exclusive feature — “sprites.” These 32 objects can be moved around the screen independently of the background or each other. Sprites can be given headings (direction) and also speeds — they move in a straight line until told to change — without slowing down the program. But they cannot draw lines like turtles. TI’s Logo makes it easy to redefine character shapes and, to a limited extent, their colors. However, since the TI relies on character graphics rather than memory-mapped graphics, the TI turtle “runs out of ink” rather quickly. As a further limitation, the TI Logo operates only on whole numbers between — 32768 and 32767. Although simple beginning programs may not require more, most people will quickly find it a limiting feature. (PILOT is also “integer only,” and I find this an inconvenience all the time.) Finally, TI’s program editor, sprite and character editors appear to be substantially less convenient to use than those of either the Atari or Apple Logos. I believe that they would be especially frustrating to new users.
Apple II+ users are offered three versions of Logo. Although this isn’t the place to analyze these deeply, an overview seems in order. All three, Terrapin Logo, Krell Logo and Apple Logo, are full-scale implementations of the language with competent graphics, list processing and editing facilities. In fact, the three are very similar, as one would expect, since they are produced by companies with similar heritages from MIT and the inventors of the Logo language.
That’s the good news about the Apple Logos. The bad news is that Apple hardware and software for any of them will cost you well over $2,000. Each requires an Apple II+ with language card, disks and an RF modulator. That compares to recent prices of less than $300 for an ATARI 400 with cassette, or less than $1,000 for the 800 with a disk drive. A school, for instance, could buy two or three ATARI systems for the price of one Apple, an attractive deal even if the cheaper systems weren’t quite as good. Atari’s Logo is at least equal to and, for most people, far better than any of the Apple Logos.
The most easily recognized advantage will be Atari’s four (count ’em, four) turtles. That compares to Apple’s single turtle. But Atari’s turtle advantage is far more than numbers. A normal, “boring” turtle can move, draw lines, erase lines, show or hide itself, and set a particular heading. The Apple systems have one normal, boring turtle.
“Dynamic” turtles can do everything boring turtles can do, plus they can change color, change shape, and can be set in motion at a given speed. In essence, they’re a cross between sprites (which can’t draw or rotate to show headings) and normal boring turtles. And Atari Logo has four dynamic turtles! The care with which this was implemented is illustrated by the screen representation; the turtle looks like a cute little turtle, not a triangle. Atari’s full picture of a turtle not only makes it easier to tell headings but immediately captivates younger programmers with a “real” turtle.
As a result of the Apple’s hardware limitations, the Apple Logos do not appear to support sounds in high-level language — an assembly language routine must be written to produce sounds. Atari Logo features full tone quality on two sound channels. The superior tonal quality was obtained by hardware mixing two of the usual voices for each channel. While BASIC programmers may miss the four voices, they’ll love the new “duration” feature. When giving Logo the command TOOT and telling it which voice to use and note to play, you also tell it how long to play that note. Your program can then go off and do its thing while the music continues to play. Nice!
Now one might say that the four turtles and sounds are non-essential. Right, but they open an entire galaxy of new microworlds. A four-player joystick-controlled road race game with acceleration, deceleration, turning, different colored cars shaped like cars, and full sound effects can easily to constructed in 50 lines. It’s a project well within the capability and interest span of third graders. Even simple turtle-graphics displays can be easily animated.
These displays are made easy by some of Atari Logo’s exclusive high-level commands. Paddles and joysticks are fully supported, as you’d expect (not so on Apple). An EACH command gives the same instructions to all active turtles and lets them perform the entire set one at a time. For instance, if the instructions draw a box, the first turtle would draw the complete box. Then the second turtle would draw the box, and so on. Essentially, the first turtle completes all instructions before the second turtle does anything.
The ASK command, on the other hand, allows all the turtles to execute the list of instructions simultaneously! Actually, the first turtle does one instruction in the list, then the second turtle does that instruction, etc., until all named turtles have completed the first instruction. Then the first turtle does the second instruction and the process repeats until all turtles have completed the list. The effect is wonderful — up to four figures drawing at the same time.
As you might expect. Atari’s 128-color pallet is much better than Apple’s seven, but there’s even better flexibility. With Atari Logo, each line is drawn with a specified pen. As in the other systems, you can change pens, and thus the colors, of the lines to be drawn. The Atari advantage shows up in the SETPENCOLOR command which allows you to change the colors of lines already drawn. This is a “color register” change so it does the entire screen instantly. The Atari supports three simultaneous pen colors, the Apple five (not including backgrounds).
I found the Atari turtle-shape editor easy to use. It displays a large-scale image of the old shape and uses simple cursor controls to design a new shape. The shapes can be animated or moved at will. They draw lines just like the usual turtle.
Even better. Atari Logo lets you use Atari’s “collision registers.” This is done by setting up a WHEN demon to watch your screen, continuously looking for an event such as a turtle touching another, a specific joystick movement, or a turtle touching a line. Some 20 different specific conditions can be monitored, with different specific actions taken whenever the event occurs. You set up demons only once. Thereafter, they look for the conditions and execute the instruction list whenever the event occurs.
I also compared the power of Atari Logo’s list processing features to Apple Logo. Since Atari Logo was developed by Logo Computer Systems, Inc. (LCSI), the same people who wrote Apple Logo, it bears an extremely close resemblance to that product. For my money Atari Logo’s “non-graphic” command repertoire is essentially as useful as the Apple systems’, yet considerably easier to use.
Krell/Terrapin includes nice error trapping commands (CATCH and THROW) which could be really useful. Also helpful would be the DEFINE command to define new procedures under program control (Atari supplies a procedure to do this). Only Krell/Terrapin allows you to save and recall screen pictures to and rom a disk file. These provide a GO command to jump around within a procedure (okay, I’ll admit that it’s a poor programming technique — which is probably why Atari didn’t include it). The TRACE command found on Krell/Terrapin allows you to step through a program one instruction at a time. Finally, Apple Logo provides a PACKAGE command to manipulate groups of procedures and variables simultaneously, and the ability to redefine the primitives themselves.
How important would these be to you? TRACE is very nice, in my opinion. As for the rest, Apple Logo lists them in the “rarely used” section of the reference manual. Almost all of these affect the process of programming, not the product itself. As for the process of programming, my review indicates that Atari’s superior keyboard already makes it far easier to use than any of the Apple Logos. That’s true despite LCSI’s obvious use of Apple-like control keys in some instance. Without special hardware, the Apple gives only uppercase letters. Atari, of course, gives both. Most educators consider early introduction of both sets of letters educationally advantageous.
Logos are heavy memory users. Atari Logo, however, seems very efficient. Under Logo, your programs use “free workspace memory” which is measured in “nodes” of five bytes. A 48K ATARI system provides at least 26%, and sometimes up to 100%, more free workspace memory than the Apple Logos. Consequently, you can run more complex programs.
Support for users is often a problem with any computer product. Not so with Atari Logo. First, the package includes an excellent tutorial in the 160-page “Introduction To Programming Through Turtle Graphics.” Next, Atari Logo provides an in-depth review of the language in a 210-page “Reference Manual.” Both of these have excellent indexes and useful examples. Probably as useful as either is the 16-page “Quick Reference Guide” which not only gives the form of each command but also explains it. A very important Atari exclusive is a live human Logo specialist at Atari’s Customer Support number, 800-538-8543.
The close similarity between Atari Logo and Apple Logo gives us a nice side effect — virtually all of the Apple Logo programs and books written by or for LCSI systems will run on the ATARI with essentially no change. Krell/Terrapin programs need only trivial changes. TI Logo is the oddball here and requires moderate rewriting. I tested the Apple Logo compatibility by typing over a dozen programs from The Young People’s Logo Association, magazines, etc; all ran perfectly.
This means that you could use any of the LCSI-oriented books easily and immediately. This not only makes a great many support materials available but also makes it relatively easy to operate a mix of ATARI and Apple machines in the classroom. All could be exploring the same microworlds, sharing materials and exchanging procedures. (Of course, it won’t be long before the kids vie for the ATARIs because of their superior turtles and sound!) Parents could buy ATARIs knowing that their children’s Apple classroom work could be brought home, and vice versa. (Of course they might ask why the school district bought such expensive machines in the first place!)
We’ll cover books in a future article. So far we’ve heard that Apple Logo by Abelson (Byte Books) and Apple Logo: In Invitation to Art and Patterns in Nature by Thornburg (Addison-Wesley) and Learning With Logo by Watt (Byte Books) are some of the best.
Some of you will ask the burning question, “Will Logo run on the new ATARI machines?” We have assurance from the Atari Logo Product Group that Logo will indeed run on the entire XL line, as well as on the older models.
There is also a significant educational question, “Does Logo really enhance learning?” Let me finish by quoting Robert R. Weiss, PhD, a school principal in the Santa Clara School District. “I cannot think of an educational goal which is not enhanced by Logo. There is no limit to what children can do with Logo, and they know it! Kids like it, and develop a sense of power and self-esteem because with Logo they can control their environment.”
This kind of endorsement strongly suggests that Logo is and will be the computer language most used in classrooms for many years to come. We recommend Atari Logo to parents and educators as a finely implemented version of the language, completely suitable for use at home and in school.
ANTIC v2.08 / NOVEMBER 1983 / PAGE 56
Atari Logo presents a full array of sound controls — a clear advantage over the generally mute Apple Logos. This article explores Logo sound and presents a sound generating program. You can use this program and your joystick to set up unending combinations of sounds and see the commands needed to put them into your programs.
The ATARI computer probably has the most advanced sound generators built into any home computer. Four voices, modulations for special effects, and easy-to-use commands give the ATARI user full sound support. When Atari was designing Logo, they discovered that many people preferred a wider range of frequencies and greater sound precision over the four-voice feature. Therefore, Logo combines the four voices into two expanded, more controllable voices. And just to be sure you are not disappointed, an automatic “duration” command was added.
Under Logo, these voices are controlled by the TOOT primitive. TOOT requires four inputs — a voice (0 or 1), a frequency (a number between 14 and approximately 9000, which represents the cycles per second for the note) a volume (a number between 0 and 15), and a duration (a number between 1 and 255 giving the numer of sixtieths of a second which the sound will play). If you program in other Atari languages these will be familiar to you. One big difference is the frequency number — Logo gives you super precision and essentially unlimited range. The duration feature is new. No more timing loops! Instead, the Logo TOOT will play each note the exact time you give it while your program is off doing something else.
Like PILOT, Logo supports only the “pure” tones. Although it’s a simple matter to develop new Logo commands to exercise the special effects, we’ll leave that for another article. Logo compensates, however, by giving us a sound “envelope” command. Imagine a sound plotted on a graph with loudness on one axis and time on the other. The normal ATARI sounds are silent one instant, then full on (at whatever loudness you select) the next. They stay at full strength until turned off, which also occurs instantly. Most sounds in the world are not like this. A piano, for instance, starts at full loudness when the hammer strikes but rapidly tapers off to silence. Engineers call this “decay.” Logo’s SETENV command allows you to set simple decay rates independently for each of the two voices. Now, you can turn a computer sound into a piano sound with a single instruction!
Enough of the sales pitch! Let’s look at the program. The “top level” procedure is START, naturally. It begins by clearing the screen with a “ClearText” command and follows by PRinting the headers. A series of MAKE commands sets up the variables we’ll be using later. Logo uses two types of variables — “locals” which are defined in a procedure below the top level, and “globals” which are defined at the top level. Global variables operate in all procedures; locals don’t. This means that a local variable name can be used in a second procedure and it won’t have the value assigned to it previously. This is nice because you can then patch procedures together without worrying about conflicts. BUT, each time a subprocedure sets up a local variable, it uses up space. Note the MAKE "X command in START. That variable is used in nine sub-procedures. When it was a local variable, the program did a “garbage collection” (i.e. stopped to reclaim unneeded space) every four cycles. After I defined it as a global variable at the top level, the program ran 31 cycles between collections!
Drop down a line or two. The (PR [\ \ ]... command illustrates how to get Logo to print a formatted line. The backslashes save a space, simple. To save exactly two spaces takes ingenuity — the [ ] gives one space in addition to the one space which Logo forces between all words.
The (PR CHAR 28… line illustrates printing graphic characters on the screen. The CHAR command outputs the character with the ASCII (decimal) value of its input (in this case, 28 is an arrow). Sometimes, you can see that our Logo was developed by people accustomed to the constricted world of Apples (which don’t allow you to use the graphics character sets). Oh well, there were some compatibility advantages, I guess.
START yells for TOOTS which promptly reads JOYstick and puts that value in the variable "X. I find it difficult to know when to use quotes and when a colon before a variable name. It boils down to something like this — when you want to put a value into a variable or to refer to it in general, use the quotes; when you want the value itself in the variable, use the colon. The explanation is in the manual but it requires careful reading.
The next line, IF :X = 6…, appears awkward. We didn’t say IF JOY = 6 because that doesn’t seem to work. It is reasonable to expect that you could use the output of a primitive in an IF statement; but, you can’t. Use a MAKE earlier, and then the IF.
The same line uses a new command, CHANGE. The power of defining new commands is what Logo is all about. 1 defined CHANGE (it’s listed down below) to take any input value (in this case, :POINTER), increment it by a second number (-1), but, if the new number is less than a minimum (0) make it equal the maximum (7). Conversely, if the new number is greater than the maximum (7), CHANGE makes it into the minimum. Neatest, you can feed the CHANGE any set of values, increments, minimums and maximums. The command is used in nearly all the sub-procedures to make sure values for the TOOT and SETENV commands stay in range.
If the joystick isn’t pulled left or right (values 6 or 2), TOOTS falls through to one of eight subprocedures used to set each variable in the sound system. Most of these are simple procedures and very repetitive — in fact, just type one and EDIT it to change the name and the variables.
The sub-procedures controlling frequency and duration (SETFRE0 and SETDUR0) illustrate the compound AND NOT operations to control program flow. That sequence says “IF the joystick is NOT pressed AND IF the value in variable X is 0, then …” It’s easier than PILOT’s linked conditionals, but placing the AND in front seems awkward. After learning the syntax, however, you can use it to link any number of conditions without typing AND over and over.
As a last tidbit for this column let’s look over the CHANGE command. Notice that the “calling procedure,” SETENV1 or whatever, gives the CHANGE command and a list of variables. In SETENV1, the first variable is :ENV1, the value to be put into the SETENV command. But when CHANGE starts, it calls that number VAL. After operating on :VAL to produce :V, CHANGE outputs V to the MAKE command in SETENVl which then places it into the variable named "ENV1. Later, this value is used to set the envelope. This ability to pass variables without name conflicts is a powerful feature not found in BASIC or PILOT.
Next month we’re in for a treat — a Player/Missile treatment to make PILOT’s turtle visible!
TO TOOTS MAKE "X JOY 0 IF :X = 6 [MAKE "POINTER CHANGE :POINTER -1 0 7] IF :X = 2 [MAKE "POINTER CHANGE :POINTER 1 0 7] SHOWPOINTER IF OR :X = 6 :X = 2 [TOOTS] IF :POINTER = 0 [SETENV0] IF :POINTER = 1 [SETFRE0] IF :POINTER = 2 [SETVOL0] IF :POINTER = 3 [SETDUR0] IF :POINTER = 4 [SETENV1] IF :POINTER = 5 [SETFRE1] IF :POINTER = 6 [SETVOL1] IF :POINTER = 7 [SETDUR1] TOOTS END TO START CT SETCURSOR [3 5] PR [SET __TOOT 0___ SET __TOOT 1___] SETCURSOR [3 6] PR [ENV FRE VOL DUR ENV FRE VOL DUR] MAKE "ENV0 0 MAKE "ENV1 0 MAKE "FRE0 20 MAKE "FRE1 20 MAKE "VOL0 10 MAKE "VOL1 10 MAKE "DUR0 30 MAKE "DUR1 30 MAKE "POINTER 0 MAKE "X 0 SETCURSOR [0 8] ( PR [\ \ ] :ENV0 [\ ] :FRE0  :VOL0  :DUR0  :ENV1 [\ ] :FRE1  :VOL1  :DUR1 ) SETCURSOR [9 14] ( PR CHAR 28 CHAR 29 [CHANGES VALUES] ) ( PR [\ ] [** HOLD BUTTON FOR FAST CHANGE **] ) SETCURSOR [8 17] ( PR CHAR 30 CHAR 31 [TO CHANGE FUNCTION] ) TOOTS END TO SETENV0 MAKE "X JOY 0 IF OR :X = 2 :X = 6 [TOOTS] IF :X = 0 [MAKE "ENV0 CHANGE :ENV0 -1 0 10] IF :X = 4 [MAKE "ENV0 CHANGE :ENV0 1 0 10] SETENV 0 :ENV0 SAYVALUES TOOTER SETENV0 END TO SETFRE0 MAKE "X JOY 0 IF OR :X = 2 :X = 6 [TOOTS] IF AND NOT JOYB 0 :X = 0 [MAKE "FRE0 CHANGE :FRE0 -10 15 9000] IF AND JOYB 0 :X = 0 [MAKE "FRE0 CHANGE :FRE0 -100 15 9000] IF AND NOT JOYB 0 :X = 4 [MAKE "FRE0 CHANGE :FRE0 10 15 9000] IF AND JOYB 0 :X = 4 [MAKE "FRE0 CHANGE :FRE0 100 15 9000] SAYVALUES TOOTER SETFRE0 END TO SETVOL0 MAKE "X JOY 0 IF OR :X = 2 :X = 6 [TOOTS] IF :X = 0 [MAKE "VOL0 CHANGE :VOL0 -1 0 15] IF :X = 4 [MAKE "VOL0 CHANGE :VOL0 1 0 15] SAYVALUES TOOTER SETVOL0 END TO SETDUR0 MAKE "X JOY 0 IF OR :X = 2 :X = 6 [TOOTS] IF AND NOT JOYB 0 :X = 0 [MAKE "DUR0 CHANGE :DUR0 -1 0 255] IF AND NOT JOYB 0 :X = 4 [MAKE "DUR0 CHANGE :DUR0 1 0 255] IF AND JOYB 0 :X = 0 [MAKE "DUR0 CHANGE :DUR0 -10 0 255] IF AND JOYB 0 :X = 4 [MAKE "DUR0 CHANGE :DUR0 10 0 255] SAYVALUES TOOTER SETDUR0 END TO TOOTER TOOT 0 :FRE0 :VOL0 :DUR0 TOOT 1 :FRE1 :VOL1 :DUR1 END TO SAYVALUES SETCURSOR [3 8] PR :ENV0 SETCURSOR [7 8] PR :FRE0 SETCURSOR [11 8] PR :VOL0 SETCURSOR [15 8] PR :DUR0 SETCURSOR [19 8] PR :ENV1 SETCURSOR [23 8] PR :FRE1 SETCURSOR [27 8] PR :VOL1 SETCURSOR [31 8] PR :DUR1 END TO SETDUR1 MAKE "X JOY 0 IF OR :X = 2 :X = 6 [TOOTS] IF AND NOT JOYB 0 :X = 0 [MAKE "DUR1 CHANGE :DUR1 -1 0 255] IF AND NOT JOYB 0 :X = 4 [MAKE "DUR1 CHANGE :DUR1 1 0 255] IF AND JOYB 0 :X = 0 [MAKE "DUR1 CHANGE :DUR1 -10 0 255] IF AND JOYB 0 :X = 4 [MAKE "DUR1 CHANGE :DUR1 10 0 255] SAYVALUES TOOTER SETDUR1 END TO SETVOL1 MAKE "X JOY 0 IF OR :X = 2 :X = 6 [TOOTS] IF :X = 0 [MAKE "VOL1 CHANGE :VOL1 -1 0 15] IF :X = 4 [MAKE "VOL1 CHANGE :VOL1 1 0 15] SAYVALUES TOOTER SETVOL1 END TO SETFRE1 MAKE "X JOY 0 IF OR :X = 2 :X = 6 [TOOTS] IF AND NOT JOYB 0 :X = 0 [MAKE "FRE1 CHANGE :FRE1 -10 15 9000] IF AND JOYB 0 :X = 0 [MAKE "FRE1 CHANGE :FRE1 -100 15 9000] IF AND NOT JOYB 0 :X = 4 [MAKE "FRE1 CHANGE :FRE1 10 15 9000] IF AND JOYB 0 :X = 4 [MAKE "FRE1 CHANGE :FRE1 100 15 9000] SAYVALUES TOOTER SETFRE1 END TO SETENV1 MAKE "X JOY 0 IF OR :X = 2 :X = 6 [TOOTS] IF :X = 0 [MAKE "ENV1 CHANGE :ENV1 -1 0 10] IF :X = 4 [MAKE "ENV1 CHANGE :ENV1 1 0 10] SETENV 1 :ENV1 SAYVALUES TOOTER SETENV1 END TO SHOWPOINTER SETCURSOR [3 9] PR [\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ] IF :POINTER = 0 [SETCURSOR [3 9]] IF :POINTER = 1 [SETCURSOR [7 9]] IF :POINTER = 2 [SETCURSOR [11 9]] IF :POINTER = 3 [SETCURSOR [15 9]] IF :POINTER = 4 [SETCURSOR [19 9]] IF :POINTER = 5 [SETCURSOR [23 9]] IF :POINTER = 6 [SETCURSOR [27 9]] IF :POINTER = 7 [SETCURSOR [31 9]] PR [^^^] END TO CHANGE :VAL :CHG :MIN :MAX MAKE "V :VAL + :CHG IF :V < :MIN [MAKE "V :MAX] IF :V > :MAX [MAKE "V :MIN] OUTPUT :V END
ANTIC v2.11 / FEBRUARY 1984 / PAGE 23
Ken Harms, our Contributing Editor for the Logo/PILOT department, is Vice President of Administration for the California Division of the American Cancer Society.
When Atari decided to implement Logo, it chose to make its version compatible with Apple Logo, which is produced by LCSI and sold by Apple. In fact, LCSI also wrote Atari’s Logo. Although this means that we’re forced to live with a few Apple-like quirks in our version of Logo, it also means that virtually all of Apple’s Logo programs run under Atari Logo. In addition, most of the LCSI-oriented Logo books also fit our needs. Just as Atari intended, this element of compatibility between the two languages provides Atari users with access to a wealth of classroom-support materials, books, and other sources of valuable information.
This month, I’ll delve into a stack of Logo books and highlight the ones you may want to consider for your classroom or family. But first, a warning. Although all Logos are related, some relatives are closer than others.
Atari Logo’s closest relative is Apple Logo. Books based on this language (often referred to as “LCSI-Logo”) are 99% “upward compatible.” In effect, this means that Atari Logo can do everything that Apple Logo can do. But Atari Logo also offers extra features that Apple Logo doesn’t — including animated turtles, multiple turtles, and more.
The Logo books produced by Krell/Terrapin are Atari Logo’s next closest relation. TI’s Logo requires even more translation. And the TRS Color Computer’s Logo isn’t even a full Logo; it’s just a turtle-graphics package. My judgment is that the average Atari user will find that the LCSI/Apple Logo books are completely satisfactory, while the Krell/Terrapin books are acceptable. Personally, I’d leave the rest of the books alone, except those that have sections which explain how to translate material into either Apple or Atari Logo.
One of the best support sources for Atari Logo users is the Young People’s Logo Association (1208 Hillsdale Dr., Richardson, Texas 75081). A membership ($9/year for students 18 or younger, $25/year for adults) provides you with a hefty monthly newsleter, software exchange privileges and access to a bulletin board.
All of these materials are dedicated exclusively to Logo/PILOT. Although it supports several machines, each issue of the newsletter is loaded with Atari Logo programs and information, and the software exchange includes 30 disks of Atari Logo programs. A member can purchase a disk (or tape) for $10, or, even better, can send in a personal program on a disk/tape (along with return postage) and receive a disk/tape of his or her choice with 12 to 15 programs on it. And anyone can log onto the bulletin board by calling (214) 783-7548 after 7:00 pm (CST). There’s no cost for use of the board (but you pay your own phone bills, of course). It lists a number of special interest groups for Atari Logo and Atari PILOT. The board is currently set up to accept messages and handle electronic mail, but it will soon allow members to upload and download Atari programs.
Jim Muller, the founder of the Young People’s Logo Association (YPLA), is also coauthor, with Bearden and Martin, of The Turtle Source Book (200 pages, Reston Books, $21.95). This excellent workbook-style manual is designed for the elementary classroom but can probably be used by most families, if an interested adult is present. The books does a good job of covering turtle graphics, and is one of the few books on the subject whose language level is appropriate for youngsters.
Apple Logo by Harold Abelson (217 pages, Byte/Neforan Hill, $15.95) is one of the few books on Logo that covers list processing as well as turtle graphics. Although Atari users will have to convert the sections on I/O and paddle use to Atari Logo, Abelson provides us with a rich vein of new words (commands) for Logo, and a lucid explanation of advanced list handling. He also covers numerical calculations and program-logic controls by means of examples that I found helpful.
All in all, this is a well-rounded, solid book; the language level is high school or above, and the pages are dense with text. I’m hoping to see an Atari version soon. (By the way, watch out for Logo for the Apple II by the same author. It’s based on MIT’s Logo and is not quite as useful as Apple Logo, although it does supply a conversion table).
Learning with (Atari) Apple Logo by Daniel Watt (358 pages, McGraw Hill, $19.95) is an excellent text for teaching Logo to a class or a parent, child, spouse or friend. Watt combines cartoons with numerous “Helper’s Hints” that teach the “helper” to help the learner. The result is that both will learn. The book’s language level — simple in the cartoon sections and adult in the Helper’s Hint sections — is appropriate. Like Apple Logo, it helps you to build an excellent repertoire of words (commands), and it includes one of the best explanations I’ve seen of the names, objects and values used in Logo.
Watt also provides a simple game, SHOOT, which should be of interest and value to the budding Logo programmer.
This book is well illustrated and contains many interesting projects and pieces of good advice for teachers. I wasn’t able to find the Atari version on the book shelves, but I was impressed with the Apple text. Watt’s Learning with Logo is based on Krell’s Logo and, therefore, isn’t as helpful, but it’s still useful if it’s all you can find.
The Source Book also includes off-computer exercises that help to introduce the concepts of turtle graphics. In addition, a number of stickers are included with the workbook; for example, it includes numerals that can be attached to the CRT screen to make a clock/time-reading program come alive. Finally, where appropriate, the book’s activity pages are reproducible, so that a full classroom can use a single source book.
Although I haven’t seen a copy yet, Reston Books should have a second YPLA book out by the time this column reaches you. 123 My Computer and Me (Reston Books, $10.95), by Donna Bearden, is a “fun” companion to the Source Book. It’s designed for the individual Logo explorer in the eight-to-twelve age group. Like the Source Book, it stresses turtle graphics.
Discovering Apple (Atari) Logo by David D. Thornburg (173 pages, Addison-Wesley, $14.95) is probably the most complete, and the most beautiful, treatment of turtle graphics you can find. An Atari version of the book should be available by the time you read this, but it wasn’t in yet at any of the book stores I visited.
Thornburg explores the Logo user’s world of shapes and planes with an eye that is always sensitive to the “larger meaning of things.” Although some passages may be difficult for youngsters, all will benefit from the author’s insights and will enjoy the beautiful patterns that his always-simple programs create. Thronburg covers many advanced topics, including “tiles,” tessellations, “squrals,” fractals, trees, arcs, cricles, and spirals, and he makes them both understandable and inspiring. He’s also the only person I know of who’s come up with a convincing explanation of why you need to know about prime numbers: you can use them to draw stars! Twelve color photos enhance an already enjoyable book.
Apple Logo Primer by Gary Bitter and Nancy Watson (206 pages, Reston Books, $14.95) offers a unique approach: It includes a section for the complete novice, one for people who are generally familiar with Logo, and a third section on the history of the language. Graphic outputs are illustrated by screen photos (most books use printed graphics) that are realistic but often muddy. The section on list processing is short but helpful.
One of the book’s nice touches is that the authors assign memorable words, such as “Open a blank” for Control O, to help users learn Logo’s “weird” control commands. The practice activities made me feel like I was back in school. The language is occasionally tough for kids — “alternative” is used instead of “choice,” and “identical results” is used in place of “the same thing” — but advanced sixth graders should be able to handle it. The primer’s strongest feature, in my opinion, is an excellent index/glossary that often tells you what you need to know without forcing you to turn to the referenced pages. Its excellent cover-reference cards round out a thoughtful approach.
Introductory Logo by Peter Ross (241 pages, Addison-Wesley, $12.95) looked interesting at first sight. Unfortunately, that’s as far as I got. Its dot-matrix printing looked so ugly that I didn’t read the text.
Several excellent Logo texts are currently available, and more are on the way. In particular, you should watch for Atari-specific editions of existing Apple books. I’ll continue to review materials as they become available. In the meantime, the books I’ve mentioned this month should provide a good foundation for your Atari Logo library.
ANTIC v2.12 / MARCH 1983 / PAGE 28
The Canadian association with the Logo computer language is almost as old as that of Logo itself. The story begins with Guy Montpetit, a Québécois, and his friend, Seymour Papert, who both studied under theorist Jean Piaget in Geneva back in the early 1960’s. Papert left Geneva to work and study at MIT, while Montpetit started a few small businesses, including a research lab in Montreal. They stayed in touch.
In 1970, the Logo group was established within the Artificial Intelligence Lab at MIT. Shortly after, in 1971, Montpetit decided to introduce Logo into Canada. In Ottawa, he managed to connect up to a mainframe government computer, a PDP-11; his system used terminals at a school in Longueil, one of Montreal’s eastern suburbs. His work with Logo there stirred much interest, and members of the MIT group frequently came up to see what he had accomplished.
In 1974, Guy took time off from his Ottawa work and moved to Boston, to be closer to his old friend Papert and the MIT experiments. Montpetit soon realized the need for finding an implementation of Logo that would make it acceptable to the world outside the university. In 1980, back in Canada, he formed a company called SGT (General Turtle Corporation) and got a contract to design and manufacture business computer work stations thar used Logo as the operating language. With SGT, Montpetit developed a number of business applications for Logo, including a word-processing package. But response from buyers was too small to keep the company afloat, and SGT soon went bankrupt.
Undaunted in his faith that Logo was an important computer language, Montpetit convinced Papert and other MIT players — Marvin Minsky, Cynthia Sulliman, and Brian Silverman (another Canadian) — to found Logo Computer Systems Inc. (LCSI) in Montreal. The new company, formed across a kitchen table one evening, was dedicated to creating a new implementation of Logo that would run on the Apple computer. MIT had already licensed Texas Instruments, Terrapin, and Krell to sell a microcomputer version of Logo, but what LCSI was after was a new, reconstructed implementation, something redesigned from the ground up on their LISP-based computers.
The LCSI group sought out local talent to help them develop the company. In order to give the company a marketable image, they brought in Jim Baroux, a veteran of the corporate world with extensive sales and marketing expertise. To stay close to MIT development, LCSI maintained a lab in Boston, where Papert and Minsky worked. Papert became the media spokesman for both Logo and LCSI, a role Baroux created, because he saw the new company’s need for an articulate expert who could talk to the press, to governments, and to educators with authority. Baroux’s efforts were so successful that Logo became a conversation item for people who didn’t even own a computer!
Meanwhile, under Brian Silverman’s sleepless efforts, LCSI polished up and brought forth its first product: Apple Logo. This was sold to the Apple Computer Corporation and marketed under Apple’s own label, a unique contract for the industry at that time.
The public response was enthusiastic, and Logo became a respected term in the vocabulary of educators. This version was to win LCSI the Best Microcomputer Software of the Year Award, presented by the Learning Periodicals Group. Apple Logo again gained prominence when Apple chose it as the only software to accompany their give-away computers to schools in the “Kids Can’t Wait” program.
Not long after Apple Logo’s release, LCSI found itself at the center of world attention, with major corporations asking almost daily for an implementation for their machines. Japan, in particular, has been interested in Logo, and many Japanese executives and researchers have come to Canada to work with LCSI.
By mid-1983, LCSI had 15 contracts to develop Logo for various machines: the IBM-PC, Atari 400/800/1200XL, DEC’s Rainbow and 350, Europe’s large Thomson Brandt company’s model TO-7, the Fujitsu computer, Coleco’s Adam, the Timex Spectrum, an Apple Sprite Logo (a version with graphics to challenge TI’s or Atari’s), a Music Logo, and more.
Brian Silverman proved to be the guiding light of Logo’s technical development. Tireless, brilliant and farsighted, Brian has been offered positions by many of the major computer companies. Loyal to LCSI however, Brian began developing an entirely new version of the memory-hungry language for use in the educational field. Brian foresees this as a huge potential market. The first product to use this new implementation is Atari Logo, a surprisingly powerful program packed into a tiny 16K of ROM. (Apple Logo takes 48K!)
From the beginning, LCSI has consistently pointed out that Logo is not merely Turtle Graphics, but a sophisticated language with powerful list-processing capabilities. Logo is not just another PILOT, a language designed to allow educators to develop curriculum and lesson programs. Nor is it simply a “kid’s” language, as many outsiders imagine it to be. Instead, it is a fully-expandable language based on the science of learning.
The big dream of LCSI is to see Logo replace BASIC as the language of choice for computing. Jean Pierre Brunet, head of LCSI’s Apple products division, says that they are “trying to package and sell thought.” He expects Logo to be for the home market “what VisiCalc has been to the business market.”
LCSI’s position in Canada has not gone unchallenged, however. Recently, Waterloo University released a version of Logo for the IBM computer. This professional, powerful version reflects Waterloo’s position as the finest computer-science school in Canada.
Ontario’s educational computer, designed and manufactured by CEMCorp, will sport a new version of Logo for its 16-bit networking system. So far, no one has been named as the developer, but certainly Waterloo and LCSI are in the running. So is a new company. Human Computer Resources, whose Richard Miller is responsible for writing a Logo which may be upgraded for the new computer. This lucrative CEMCorp contract would insure Logo a place in Ontario schools, since the government has guaranteed an initial equipment purchase of $10 million.
LCSI’s most serious competitor, in their own eyes, is not a Canadian company, but rather Digital Research, which is based in California. The company that brought us CP/M has also released Logo for the IBM-PC. LCSI sees DR as having the market credibility to present a solid challenge to their sales. However, LCSI also believes that having DR on the Logo bandwagon will lend credibility to the language.
Meanwhile, independent groups such as the Logo Special Interest Group (Sig-Logo) of the Educational Computing Organization of Ontario (ECOO), are working to spread the interest in Logo into Ontario schools. This group has scheduled a research conference at Queen’s University in Kingston and expects individuals from across North America to present papers about their work with Logo.
Dr. Bill Higginson at Queen’s produces the SigLogo newsletter, LOGO-Phile, an erratically scheduled publication which is surprisingly full of Logo information and gossip. Higginson also heads a Logo research project in provincial public schools, which is sponsored by the Ontario Department of Education. Dr. Higginson’s co-worker, Dale Burnett, wrote a popular book on Logo.
The GAMMA Institute — a think tank jointly funded by Montreal, McGill and Concordia Universities, and Ryerson Polytechnic Institute — recently released a research paper called “On Terminals, Turtles and Turning Teaching Inside Out,” which examined the impact of the personal computer on education. It concludes that researchers and educators at higher levels are very much concerned with Logo and its developments.
Elsewhere in Canada, Logo is finding strong footholds in school systems in British Columbia, Quebec, Manitoba and Saskatchewan. In Quebec, the provincial government’s “Buy Quebec” policy is helping LCSI’s Logo enter the schools, especially now that the company offers a version in French. In Manitoba, the Department of Education published a pamphlet for teachers called Getting Started in Logo, but as a beginners’ guide it lacks professionalism and direction. Surprisingly, a 1983 report from the Alberta Ministry of Education on computers in the schools completely overlooked Logo in an otherwise excellent proposal. Obviously, educators still have a lot to learn.
However, through the efforts of a handful of dedicated people in a small office outside of Montreal, Logo has become an important new element in educational strategy, with Canada in the forefront of research and applications. Perhaps, someday, LCSI’s dream that Logo will be available in every school and home will come true.
ANTIC v3.01 / APRIL 1983 / PAGE 35
The secrets of Atari’s Logo finally are beginning to emerge! This month we’ll discuss two places where you can store your machine-language code and a method that allows you to use Logo to print large letters on the screen. We’ll even be able to move turtles around on a text screen! (By the way, both of these topics were covered in direct response to readers’ requests — so if you want it, ask for it!)
First of all, Logo is not an “applications” language. That is, it was designed to serve as an environment for experimentation, rather than as a language for writing polished, arcade-style game programs. It doesn’t offer sophisticated error-trapping capabilities, or easy access to the Atari’s own special capabilities. Atari did take special pains to produce an improved Logo that is highly compatible with Apple Logo. That’s the good news. The bad news is that — as a result — we Atari users often have to deal with the Apple’s poor design as we travel in Logo’s world. Wouldn’t you love to have access to the Atari’s full-screen editor in Logo?
Logo’s memory is divided into two sections, one below the graphics screen and one above it, because Apple does it that way. As in all Logos, this memory, called “node-space,” is made up of five-byte units called nodes. This space is used to store your program and to execute its procedures. To find its way around nodespace, Logo sets up a scries of “pointers” that tell it where things are. Generally, pointers are two bytes long, and are stored low byte first, then high byte. (A byte is a character or a numerical value.)
Now we’re ready to consider the best way to store machine-language programs. But. just to make things more interesting, note that nodespace pointers are only one-byte long — the “high” byte. The pointer at 14268 directs us to the start of the first bank of nodespace, or the bottom of memory. To get this decimal address, type:
PR 256 * .EXAMINE 14268
Let’s call this address STARTONE. ENDONE, the end of the first bank, is pointed to by the high-byte at 14271. The two pointers for the second bank are STARTTWO at 14269 and ENDTWO at 14270.
Just as in BASIC, the best hiding place for machine code is an area of memory that the language processor has “forgotten.” So, just move up the bottom of memory by .DEPOSITing a new value in 14268. Logo only stores page addresses (a “page” is 256 bytes), so if you add one to the value in STARTONE, memory moves 256 bytes. But — since nodespace is made up of 5-byte nodes and five doesn’t divide into 256 evenly — it soon becomes apparent that we have to move the bottom of memory in increments of five pages each — or a whopping 1280 bytes! By the way, the folks at LCSI have warned that memory should be moved only when Logo is first booted.
If you don’t need 1280 bytes and aren’t planning to create your own turtle shapes, a good storage area is the shape table, which is ordinarily used to store the shapes you create with the shape editor This table has 256 bytes and starts at 13824. You can probably use the SETSH command sequence to install the code without a series of .DEPOSITS.
Atari computers use several processors. The one we think of as “the computer” is a 6502 microprocessor The Atari uses another processor to handle the screen display so that the 6502 can work as efficiently as possible. This is the main reason that the Atari 800XL is more “powerful” than the Apple IIe; Atari’s special processor frees the 6502 to make calculations more efficiently than the Apple can.
This special processor is called ANTIC, or the ANTIC chip. ANTIC is actually a tiny computer. It needs a special program, called a display list, to tell it how to display the data that the 6502 processor puts into memory. Each of the different display modes is simply a different program for ANTIC. So we can produce large letters by providing ANTIC with a large-character display program. The one I’ve chosen is known in BASIC as Graphics 2. Under Logo, it displays 12 lines of 20 characters in four colors.
Using the listing as our road map, let’s build a special display list for Logo. Chris Mitchell, a computer hobbyist, musician and colleague of mine who lives in Seattle, came up with the idea of using the screen buffer as a text screen. This allows us to display both the turtle and text at the same time! As a result, you can use a specially-shaped turtle as a pointer to highlight words or make the regular turtle dance around the title of your program. (Unfortunately, however, if you try to draw with the turtle either your drawing will not appear, or it will display weird characters. Sorry about that!)
To set up, we first call a Full Screen, followed by a Hide Turtle (leave this out if you want the turtle to appear on the screen) and a Clear Screen. The last step ensures that we won’t display an old drawing.
ANTIC looks for a display list (its program) at the memory address pointed to by the two-byte pointer at 560 and 561. The second line takes those values and uses them to start building a new display list. Generally, the first three values in the list are 112’s, which tell ANTIC to display blank lines (these allow for TV pictures that aren’t quite right). The next instruction, a 71, tells ANTIC that we’re going to display Graphics 2 characters.
The next two values, 17 and 59, make up a two-byte pointer to the data that ANTIC will display. At this point, things get a bit tricky. Logo uses a two-byte pointer at 14272 and 14273 to find the start of the screen buffer that we use for our data. The buffer is 960 bytes long. But we’re using only 240 bytes (12 lines of 20 bytes). As a result, if we start at the beginning of the buffer we’ll encounter 36 blank lines before seeing anything on the screen. Because of this, we simply skip 720 bytes to the 240 bytes we need. If you’re using a 64K system, use 209 and 66 instead of 17 and 59.
The next 11 pieces of data in the list are sevens. These tell ANTIC to “display this line as large letters.” Next, we send ANTIC a 65 to tell it that we’re finished. Finally, ANTIC needs the address of the next program, or display list. In this case, we simply use the values for the same display list, since we want ANTIC to jump back to the beginning and do it again.
I hope that at this point you’ll be off and running with these special displays for your Logo programs. Further information on display lists can be found in a series of articles in ANTIC by Allan Moose and Marian Lorenz (Display Lists Simplified, page 33, February/March 1983; Start Interrupting, page 24, June 1983; More Interrupting, page 54, December 1983). If there’s enough interest, I’ll cover procedures for other special displays in future columns. By the way, when you exit these special modes, use a TS (text screen) and a CT (clear text) to get everything back to normal.
TO MODE2 FS HT CS MAKE "START ( ( ( .EXAMINE 561 ) * 256 ) + .EXAMINE 560 ) REPEAT 3 [.DEPOSIT :START 112 MAKE "START ( :START + 1 ) ] .DEPOSIT :START 71 MAKE "START ( :START + 1 ) .DEPOSIT :START 17 MAKE "START ( :START + 1 ) .DEPOSIT :START 59 MAKE "START ( :START + 1 ) REPEAT 11 [.DEPOSIT :START 7 MAKE "START ( : START + 1 ) ] .DEPOSIT :START 65 MAKE "START ( :START + 1 ) .DEPOSIT :START ( .EXAMINE 560 ) MAKE "START ( :START + 1 ) .DEPOSIT :START ( .EXAMINE 561 ) END
ANTIC v3.06 / OCTOBER 1984 / PAGE 19
If 25 people are in a room the chance is 56.78% that at least two of them have the same birthday.
Puzzles like this are ideal exercises for the Logo programmer.
When solving a brain-twister with a computer, you should try to see it from at least three different perspectives. Look at the word puzzle as a problem in logic, then as a problem in math, and finally as a programming problem.
To define your word puzzle in logical terms, it’s helpful to match all the information you know against the added information you will need for solving the problem. Use any patterns, trends or relationships you can discover to create an algorithm for the word problem. An algorithm is a logical set of steps you must take to solve a problem.
Use your algorithm to design a set of equations which will define your word puzzle mathematically. Finally, translate these equations into Logo procedures which your Atari can execute.
We’ll use the Birthday Puzzle and Logo to illustrate each of these steps.
We know there are 25 people in the room, and that there are 365 days in a year (leap days are ignored). Since it is likely that a small group of people will have a wide range of birthdays, we’ll first calculate the chances of at least two people having different birthdays. We’ll subtract this result from one to find the probability of at least two people having the same birthday.
Next we’ll break the problem down into smaller pieces, and define each piece with an equation.
Consider a room with one person standing in it. We are certain that nobody else in the room shares this person’s birthday — nobody else is there. The birthday could occur on any one of the 365 days in the year. Mathematically, this probability can be represented by 365/365.
Now consider a room with only two people standing in it. The first person’s birthday occurs on one of the 365 days in the year. If the second person’s birthday is to be different, it can only occur on one of the 364 remaining days. In other words, the chances of two people having different birthdays is 364 out of 365. We can numerically represent this as 364 / 365 × 365/365.
If a third person’s birthday is to be different from the rest, it can only occur on one of the remaining 363 days. The probability of the third person’s birthday being different from both the first person’s birthday and the second person’s birthday is represented by 363/365 × 364/365 × 365/365. When a fourth person enters the room, only 362 “unclaimed” days remain. Our probability becomes: 362/365 × 363/365 × 364/365 × 365/365.
This can be abbreviated as:
(365! / 361!) / 3654
And we can malce a general equation for N people as follows:
365! / (365-(N-1))! / 365(N-1)
Again, this equation calculates the chances of at least two people having different birthdays in a room of N people. Subtract this value from one to determine the chances of two people having the same birthday in a room of N people. So our final equation becomes:
1 - 365! / (365-(N-1))! / 365(N-1)
We’ll write three short routines to solve the Birthday Problem: an input procedure, an initializing procedure, and a procedure which solves probability equations. We’ll call our procedures BIRTHDAY.PROBLEM, BEGIN.SOLVING and SOLVE.
To use the procedures, type in the listing at the end of this article with the Logo cartridge. Call the BIRTHDAY.PROBLEM procedure by typing the name of the procedure, followed by the arguments (numbers) required by the procedure. For instance, type BIRTHDAY.PROBLEM 25 to determine the likelihood of any two of 25 people in a room having the same birthday.
To use PROBLEM.SOLVING, you must type PR (or PRINT) before the name of the procedure, and follow the name with two numbers. See the examples at the end of this article.
The first procedure, BIRTHDAY. PROBLEM, accepts the variable PEOPLE, which represents the number of people in the room. Then, BIRTHDAY.PROBLEM calls the BEGIN.SOLVING procedure and tells it the value of PEOPLE along with the number 365, the number of days in the year.
BEGIN.SOLVING accepts these two values, and assigns them to the local variables EVENTS and POSSIBILITIES. The value once stored in PEOPLE is now contained in EVENTS. And POSSIBILITIES contains the number 365.
Then, BEGIN.SOLVING initializes the global variable PROBABILITY to one, and decreases the value of EVENTS by one. Finally BEGIN. SOLVING calls the SOLVE procedure and tells it the values of EVENTS and
SOLVE uses these two values to solve our probability equations. Since Logo doesn’t have a factorial function, the SOLVE routine must be used over and over again until it arrives at an answer For example, after our first trip through SOLVE, the value of PROBABILITY is 341/365. After the second trip, the value becomes 341/365 × 342/365, and after the third, the value becomes 341/365 × 342/365 × 343/365.
Just as a procedure can call another procedure — it can call itself. This call forces the procedure to run itself over and over again, until another instruction tells it to stop. The process of a procedure calling itself over and over again is called “recursion.” SOLVE is a recursive procedure, and calls itself in the fifth line.
SOLVE keeps calling itself until the value of EVENTS is zero. When this happens, the value of (POSSIBILITIES -EVENTS)/POSSIBILITIES is equal to one, and our modified factorial routine is complete. The result is subtracted from one, and printed on the screen.
BEGIN.SOLVING and SOLVE may be used with many other probability calculations, such as these two dice puzzles:
PR BEGIN.SOLVING 3 6
PR BEGIN.SOLVING 4 12
Take the time to thoroughly examine your word puzzle before writing a Logo program to solve it. Remember that there are many routes you can take to arrive at a correct answer Selecting the most direct route is a key to efficient programming.
If you don’t have an Atari Logo cartridge but have worked up a curiosity about these puzzles anyway, here are the answers . . .
Three-dice problem: 44.44% Four-dice problem: 42.71%
TO BIRTHDAY.PROBLEM :PEOPLE ( PR BEGIN.SOLVING :PEOPLE 365 ) END TO BEGIN.SOLVING :EVENTS :POSSIBILITIES MAKE "PROBABILITY 1 OUTPUT SOLVE :EVENTS - 1 :POSSIBILITIES END TO SOLVE :EVENTS :POSSIBILITIES MAKE "PROBABILITY :PROBABILITY * ( :POSSIBILITIES - :EVENTS ) / :POSSIBILITIES IF :EVENTS = 0 [OUTPUT WORD 100 * ( 1 - :PROBABILITY ) "%] OUTPUT SOLVE :EVENTS - 1 :POSSIBILITIES END