Copyright © 2008, John F. Raffensperger
I wrote this in 2001, but the events occurred four or five years before than that. Much of the story is true.
I have three kids, David (14), Peter (12), and Becky (10). They're awesome. You wouldn't believe some of the things they've done with Lego. They got started with it as soon as they could hold the parts, because I had a lot of Lego from when I was little.
I play with them almost every night for an hour or so, after dinner. When they were little, they would ask me to build Lego models for them. Most of the time, I built robots, cars, or houses. Regular things. Over their early years, it became increasingly harder to create something new and interesting. I was running out of ideas. So they had to suggest things for me to build, and I tried to build it as best I could. But these days, their models are cleverer than what I can do.
As they got older, their grandparents continued to shower them with the latest and greatest Lego sets. Peter would get the Technic helicopter, David would get the electric motor kit, Becky - the youngest - got Duplo. Lego was and is their number one plaything. They have always been quite organized with it, too, keeping the different types of pieces in separate boxes. We had a great time thinking about a taxonomy of Lego. Should they be sorted by color, by length, or by number of bumps? Of course, they developed quite a sensible taxonomy that worked for them. Ownership of most pieces, though, didn't revert to public ownership.
Over time, the children had differing amounts of Lego. Peter seemed to get the most. David, however, as the oldest, could browbeat Peter and Becky into giving up desirable parts. When Peter wanted to trade back, claiming quite correctly that the piece was his anyway, an argument usually ensued.
This sniping was beginning to be irritating. I wondered if we could do something to make sharing the Lego a little easier for all concerned. As a student of management science at the University of Chicago, I was supposed to know something about economics. One day, I proposed to the children that they establish a market in Lego pieces. I explained how a free market works. Someone would need to set prices for the various types of pieces. We would have to invent some kind of currency, say marbles. Each time anyone wanted a piece of Lego, they would have to buy it, paying the current price in marbles. The hard part would be setting prices. I figured that I would act as a benevolent dictator; in effect, they would buy and sell Lego from me.
They refused. It sounded way to bureaucratic and threatening.
Another week of arguing about Lego went by. This week saw all kinds of hurt feelings, lack of sharing, and tugs-of-war over precious plastic pieces. At the end of it, the children said they wanted to reconsider the notion of a "Lego economy."
So we implemented the Lego economy. It was simple, since they already had the parts organized. There weren't enough marbles to use for currency, so I donated a box of rusty drywall screws. At first, they called them screws, as in "three screws for the Lego man", but I suggested that they be called "points." They also used old playing cards for 10 points, and baseball cards were worth 100 points.
David suggested that prices could be set by a simple heuristic. If there are more than 20 pieces in the box, then the price is 1 point. For each number below 20, the price goes up by one point. So price p = 20 - k, where k is the number of parts left in the box. Thus, if there are k = 5 pieces left in the box, the price is 15.
Immediately, they discovered that they could earn an infinite number of points, since someone could take out a part to increase the price by one, then sell it back at that price to gain one point. So the sell price has to be one higher.
We had to count everyone's Lego in order to determine how many points to give them initially. This must have taken a couple hours - they had around 15 thousand pieces of Lego at the time. All Lego then became public, and each child was given a pile of points, corresponding to the number of pieces they had owned. The children assured me that there would be no cheating.
True to their word, they played fair, and immediately the sniping and browbeating ceased. It was clear how much each part was worth, and trades were made quickly and gently. There were a few technical problems with pricing, because one box of mixed parts really needed to be separated into two different types with separate prices, but after that, the whole thing worked like a charm. Hoarding parts was literally pointless, since it was better to turn them in at high prices to get parts more urgently needed. Occasionally, the boys generously gave points to their sister, because she was given less Lego at the various birthdays and Christmases, and she could sometimes be tempted to pay more for a completed ship than the individual parts were worth. Not a bad show for three kids, 6, 8, and 10 years old. It was really amazing how smoothly everything worked after that.
The boys wanted to keep track of their wealth, the point prices of Legos, and the quantity in each box. So they wrote down complicated lists of transactions, prices, and point totals, in little kid-penciled scrawls on long sheets of line yellow paper.
Around this time, the boys began to play with one of our computers. As we home schooled our children, my wife got a book about QuickBASIC out of the library, and they all learned together about IF and GOTO statements. They could figure out how to modify the simple game programs that came with MS-DOS, so that they could customize the colors, scoreboard, etc. Our first computer soundcard came with crude voice synthesis software that would read text files aloud. Late at night, I used to write simple jokes in a text file, and connect the voice synthesis software to the text file with Autoexec.bat, so the children would hear jokes when they turned on the computer in the morning. The accent was all wrong, but it made the kids laugh.
David asked for Microsoft Visual C++ for his 11th birthday. I had myself been programming in C for my dissertation, but didn't know much about C++. But I bought it for him, and away he went. Very quickly, the boys taught themselves Visual C++ and Visual Basic, as well as Microsoft Excel and Powerpoint ("Dad, you ought to use this for your work."). One day, David asked for help with Microsoft Access, a database program. It seems he had gotten tired writing all the transactions down, and wanted the computer to keep track of it. He wanted help calculating a person's net worth. If there are 15 parts of two-by-eights in the box, and David has 7 of them, what is his net worth? If he turns them in, the price changes. Also, someone else might turn theirs in first, changing the price. So we discussed various ways to solve this accounting problem. Eventually, David got accounts for all three kids (and two "guests") set up on Access.
The hard part, though, was getting the transactions into the computer. Eventually, David felt he needed a complete database of all the parts. Ideally, the database would contain a description and a picture of each part, perhaps even a three-dimensional model of each part. Setting this up seemed like a lot of work. Furthermore, it would not make the transactions any easier to enter. We discussed various ways that the information could be entered. Maybe we could set up a computer in the play room, so whenever anyone wanted to buy a part, they would just enter their name and the part into the computer indicating whether they wanted to buy or sell a part. The computer would keep track of prices. But this had a downside - who wanted to type all that into a computer, just to play with Lego? It was just too inconvenient.
Eventually, I offered to write a recognition algorithm for him. I agreed that if David would (1) set up the database - including the 3-dimensional model of each part, (2) write a dynamically-linked library to connect my recognition algorithm to his database, then I would (1) buy a digital camera and a microphone to connect to the computer, and (2) write an algorithm that would recognize the type of piece and the person. So all they would have to do is wave the Lego piece in front of the computer and say, "buy" or "sell", and the computer would log the transaction at the correct price.
Well, David called my bluff. I had no intention of writing any such algorithm, nor did I have any idea of how to do it. But I went through the motions. As soon as we had the digital camera, the boys worked together to scan images of the Lego pieces (storing them as bitmaps), then converted them with Corel Draw into vectorized models, and saved them as AutoCAD files. Sometimes the vectorization didn't work properly, so they had to do a little custom drawing. When that was done, they came to me and demanded the recognition algorithm.
But I pointed out that they still didn't have a library that would connect my algorithm to their database. After arguing about suitable calling parameters, David sat down to work with C++. Meanwhile, I ran off to the university library and started digging up recognition algorithms.
We never did get it working perfectly. The computer could recognize the Lego pieces with 99.91% accuracy, good enough for the kids, but I couldn't get the computer to distinguish the two brothers. It could identify Becky all right, but not the boys. They just look too much alike. So they had to say their names when they made a transaction. They complained no end about it. "Look," I said, "all you have to do is wave the part in front of the computer and say 'buy' or 'sell' and your name. Is that so hard?" But they felt I had not held up my end of the bargain, because they had to say their name. In fact, they didn't even have to say a name - David's voice has started to change - they could say anything, and the computer would distinguish their voices. Once I realized that, I could identify them from their voices alone, and they didn't even need to say their names.
A couple years ago, Becky built a robot that could pick up parts, roll away, and set them down again. It was simple enough. Actually, a lot of it came from the Lego instructions. The batteries kept running down, I think because they were leaving the thing on all night, so she put a solar panel on it to recharge the batteries. Anyway, it was a cute robot. She called it Bumpy, since it kept bumping into things.
The boys had the idea that we could get the robot to pick up and sort the Lego, since we had an algorithm that could recognize the pieces. All we had to do was figure out how to connect the computer to the robot. That turned out to be hard. We had to wait until Christmas when Grandpa bought some of the key equipment, an infrared port and an on-board processor. After that, it was easy.
David said that all we had to do was keep the Lego boxes in the same place, so the robot would know where to put it. But Peter suggested that the robot could search for the box, since it could recognize the pieces in the box. It would help if we just added vector models of the boxes to the database, so it could recognize the box, too. We programmed it so the robot would remember where the box was last placed, and search there first.
Unfortunately, the camera was still stuck on the computer. Bumpy didn't have enough on-board power for a camera, so on the computer the camera stayed. This meant that poor Bumpy could not recognize Lego out of the field of view of the camera. We had to set the computer on the floor. The boys swept the Lego to the middle of the room, and put Bumpy to work during dinner. By the time we got to dessert, Bumpy was done.
The first time this happened, Becky completely lost control. It turned out that Bumpy had broken apart three of Becky's Lego doll houses and put all the pieces away. To make matters worse, we had forgotten to keep track of whose Lego was being put away. Bumpy just put away all the Lego without paying the proper number of points into each child's account. The boys sweetly helped Becky rebuild her doll houses, and they made reasonable guesses as to how many pieces each child had out, so no one would be shortchanged by the mistake. Eventually, the children realized that the database knew how much Lego each child had, and David's accounting algorithm was put to work to calculate total wealth. Plus Peter added a bit of code to prevent Bumpy from breaking completed models.
About six months ago, Peter met a boy at school named Matthew. Matthew is a good kid, on the whole, just misbehaved sometimes. Anyway, one day Matthew was over at our house playing with the Lego. The kids had him set up in the computer in the "guest" account, and gave him a bunch of points to play with up front. Around 5 o'clock, his mother called him home for dinner. Peter looked around and realized that Matthew had pulled out a lot of Lego, way more than they had given him. To add injury to insult, some special pieces were missing. Since we already had a scan of Matthew, it was easy for Peter to add code that checked if Matthew tried to walk away with parts, as long as it happened when he was in front of the computer's camera. We never let him know how we figured it out, we just stopped him at the door.
Nowadays, whenever the children get a new Lego kit, the first thing they do is dump out all the parts and set Bumpy to putting them away into their proper boxes, sorted by type. Then they scan the instructions, vectorize the bitmaps, and dump a database of parts in the kit. For a medium-sized model, this usually takes four or five minutes. Bumpy retrieves all the pieces in good order, selecting where possible the colors according to each child's preselected color preferences.
The kids still haven't gotten Bumpy to do a very good job of assembling kits, though. The problem is that some Technic parts require quite a bit of force to put together, and Bumpy just isn't an industrial-strength creature. I don't feel comfortable letting the children play with overly powerful machines. So the children still have to intervene occasionally at certain steps, while Bumpy sits by idle. Perhaps its not a good thing. Kids nowadays just don't have a chance to think for themselves, and it's important that they have a chance to be creative, and actually put things together with their own hands.