July 27, 2005
A Programming Question
Last week, Anthony (my 6-year-old son) came home from summer camp and tapped me on the shoulder while I was working in my home office.
"How long does it take to make a computer game?" he asked.
I looked up from my work for a second. "Maybe five years." Anthony is always full of such questions, and sometimes I have no idea where they come from. He never had too much of an interest in my line of business before.
"That's a long time," he said.
He stood there, next to me, watching me debugging code for a few minutes. Then he spoke up again.
"How about a really easy game. Like a pet show?"
Ah hah. Now I see what he is asking....
"Anthony, do you want to make your own computer game?"
"Yeah, and Sam does too. And his sister too." Sam is Anthony's friend from summer camp. It turns out that Sam and his sister and Anthony have been coming up with lots of ideas for computer games, and they want to make them. Sam's sister wants to program a pet show.
"Maybe we can do something," I promise him, "Maybe tomorrow."
But really, I am puzzled. I am not sure if there is a good way to answer his question in 2005. It is not 1979 anymore.
Freeze Frame: 1979
In 1979, American suburbia and geekdom was swept by the arrival of the new "Personal Computers" from Atari, Commodore, Apple and Radio Shack. Those years, any kid who had a computer at home was the envy of his friends.
"Hey, can I go to Sam's house and play computer games?" my son asks today. In 1979 I often asked the same question. But the friend was Dennis Yee, and his computer was an Atari 400 running a 1.8Mhz 6502 attached to a TV set and a tape recorder.
Let me tell you, that beige UFO-shaped computer was way more interesting than a home PC today. In 1979 Dennis was the only kid I knew anywhere who had of these "computers". And so all the neighborhood kids would find their way to his house, where the computer was set up on the dining room table, ready to show itself off to a crowd.
It did not matter much that the software was primitive back then. It was all great stuff, so new, so neat. You can play Space Invaders at home! And people were writing new software all the time - I remember lusting after Caverns of Mars and puzzling over the amazing Zork games from Infocom.
By 1981, I no longer needed to be a spectator. Keeping up with the Joneses, my dad proudly came home from a trip to California with an Atari 800 that year - straight from Atari. Now, what to do with it?
It was time to read some magazines.
The early Personal Computer Rags
Compute. Byte. Creative Computing. Antic. Analog. Did you ever read these? The early "trade rags" were overflowing with exciting content, full of ads and articles and letters on the new devices. They were thick magazines! As a 11-year old in 1982 I remember flipping through newly arrived issues of Compute and thinking, "by the time I read 300 pages, the next issue will be here!"
The magazines wrote all about what you could do with these early computers. That basically came down to three things:
1. You could play games.
Actually, there was a fourth thing you could do, and these magazines were chock full of it, more than anything else.
4. You could type in programs that you didn't understand.
They were filled with source code for fun programs - they were, in a sense, the earliest "open source" for personal computers. I remember spending days and days typing in a program called "Gold Miner" which was basically a game where you try to blow up rock to get gold without getting trapped in the mine. And then I spent days and days playing it. What a great game, and how empowering to be able to have typed it in.
I also typed in a program for making your own Atari 800 fonts, and then I invented a whole bunch of fonts. I typed in a program that let you enter machine code directly, and then I used that program to enter an high-performance program for a cool video game that involved spaceships.
At first, I had no idea what I was typing in. I remember distinctly the day Dennis Yee explained to me that a REM statement - a BASIC "remark" - was actually ignored by the computer. What a revelation!
I had previously been carefully typing in all the REM statements I saw in the magazines, meticulous with spelling and all, because these REM statements were the only part of the program that I could understand. Surely, I had thought, they must have been important.
The realization that the rest of the program was the important stuff was the beginning of comprehension.
At one point, my Dad's friend Phil Baker (who worked for Atari in the early 1980s) sent home a real programming assignment for me. Instead of typing in programs I didn't understand, why not try inventing my own program? "Try writing a program that prints out prime numbers," he suggested.
Wow, what a challenge. I understood that BASIC could do math, that it had variables, and that it could do loops, but then I was totally stuck. See, when you did "5/3" in ATARI BASIC, it would give you 1.6666667, and I had no idea how to tell the computer how to use that fact to know that five was not divisible by three.
In the letter he had written with his puzzle, Phil Baker had also clipped the answer. I remember that very clearly too - it was a Polaroid picture of the source code. White on blue fonts, it was literally a full color screen shot of his TV - this was way before inkjet, before laser, before even widespread dot matrix printing.
When I took a peek at his code, I discovered that my program had been right! Except that I had been missing a crucial piece of knowledge. There was an "INT" function built into BASIC that would convert a floating-point number to an integer by rounding down. What I was missing was knowing how to say "is x an integer?" by saying "IF INT(x) = x".
10 FOR I = 3 TO 100 20 LET J = 2 30 IF INT(I/J) = I / J THEN GOTO 70 40 LET J = J + 1 50 IF J < I THEN GOTO 30 60 PRINT I 70 NEXT I
The prime number sieve was my first real program. It was the first program I actually understood, and the first time I realized that I could really do something on my own with the computer.
Guess My Number
Then I remember reading Albrecht, Finkel, and Brown's book on ATARI BASIC, and really having a good time with it. Everything in that book seemed so clever to me. It still makes a good read today - the whole content is online! My favorite part was putting together the games - and understanding and tweaking and improving them.
Here was one 10-liner game, a classic gem: Guess My Number.
100 REM**GUESS MY NUMBER - A COMPUTER GAME 110 LET X=INT(100*RND(1))+1 120 PRINT 130 PRINT "I'M THINKING OF A NUMBER FROM 1 TO 100" 140 PRINT "GUESS MY NUMBER!" 150 PRINT : PRINT "YOUR GUESS", INPUT G 160 IF G < X THEN PRINT "TRY A BIGGER NUMBER." : GOTO 150 170 IF G > X THEN PRINT "TRY A SMALLER NUMBER." : GOTO 150 180 IF G = X THEN PRINT "THAT'S IT! YOU GUESSED MY NUMBER" RUN I'M THINKING OF A NUMBER FROM 1 TO 100 GUESS MY NUMBER! YOUR GUESS? 50 TRY A BIGGER NUMBER. YOUR GUESS? 75 TRY A SMALLER NUMBER. YOUR GUESS? 68 TRY A BIGGER NUMBER. YOUR GUESS? 72 TRY A BIGGER NUMBER. YOUR GUESS? 73 THAT'S IT! YOU GUESSED MY NUMBER. READY
The wonderful thing about programming games was, you could play them. When you were done, the code didn't just sit there. Your program could surprise and challenge and enteratain you.
BASIC Was Real
The beauty of writing in BASIC on the ATARI was that there was only a small gap between writing programs like this and writing "real" joystick-and-animation games.
In the early days, commercial software was often written using BASIC. Almost everything you could imagine doing, you could do. You had access to graphics, sound, and devices. And when you ran out of gas in BASIC, there were PEEK and POKE and ways of embedding a little machine language in your BASIC program. The same language for beginners was used by the pros.
Soon after "Guess My Number" I wrote a little game I called "Canyon Runner" where you used a joystick to navigate an ASCII "Y" character down a randomly generated twisting channel of ASCII obstacles. Every fraction-of-a-second the terrain would scroll upwards by one space.
XXXXXXXXXX Y XXXXXXXXXXXXXXXXXXXX XXXXXXXXXXX XXXXXXXXXXXXXXXXXXX XXXXXXXXXX XXXXXXXXXXXXXXXXXXXX XXXXXXXXX XXXXXXXXXXXXXXXXXXXXX XXXXXXXX XXXXXXXXXXXXXXXXXXXXXX XXXXXXX XXXXXXXXXXXXXXXXXXXXXXX XXXXXXXX XXXXXXXXXXXXXXXXXXXXXX XXXXXXXXX XXXXXXXXXXXXXXXXXXXXX XXXXXXXXXX XXXXXXXXXXXXXXXXXXXX XXXXXXXXXXX XXXXXXXXXXXXXXXXXXX XXXXXXXXXXXX XXXXXXXXXXXXXXXXXX XXXXXXXXXXX XXXXXXXXXXXXXXXXXXX XXXXXXXXXXXX XXXXXXXXXXXXXXXXXX XXXXXXXXXXXXX XXXXXXXXXXXXXXXXX XXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXX XXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXX XXXXXXXXXXXXXXXXX XXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXX XXXXXXXXXXXXXXX XXXXXXXXXXXXXXX XXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXX XXXXXXXXXXXXXXXXX
"Even more fun than Gold Miner," was my little brother's verdict. "Though maybe not as fun as Star Raiders." (Star Raiders for the Atari 800 was, IMO, one of the most well-crafted games in history.)
In 1979, you could write "fun" games with the very same tools you were using to learn. The bar was low, and the ramp for learning was gradual and smooth.
Fast forward to 2005. In the intervening 26 years, computers have become many thousands of times more powerful. What is considered a "fun computer game" has changed enormously. Kids have been exposed to highly complex three dimensional computer games by the time they are 5 years old. They take CD-ROM multimedia cartoon games for granted.
At the same time, the art of programming a PC has grown from a little hobby to a huge profession. The standards of quality are high, and the modern tools for programming are complex. For example, the professional tool of choice, C++, is a beast of a language, and you can pay Microsoft or Borland hundreds of dollars to secure a copy for your PC.
Everybody owns a computer, but has anybody programmed theirs? Will there ever be another generation of programmers like the ones who were growing up in 1979? Is there any room for a 6-year-old hobbyist?
Maybe there is. But "COMPUTE!" magazine has long since gone out of print, so in 2005 we will need to bushwack a little bit more than we had to in 1979.
There is still a way to hack like a beginner, and we can still have fun.
In the next article I will talk about Anthony's experience in programming my modern 2005 computer as a total beginner.Posted by David at July 27, 2005 07:30 AM
|Copyright 2005 © David Bau. All Rights Reserved.|