Squeakytime 2: IT’S ALIVE

Last night I couldn’t help going back to Squeak to play with it after the kids were to bed. I decided to make a critter to play with. I drew a fat red spider with googly eyes and named it Goober.

One of the first things I made Goober do was run away. I gave him a wiggly, back-and-forth run, and I made it so that when he got to the edge of his box he’d make an almost complete turn. I set the run to start when the mouse hovered over him, and to stop when he hit the edge of his box.

It was cool… until I thoughtlessly closed the little scripting box that constituted Goober’s brain. It would be easy to get it back of course and keep programming him…….. if I could right-click on him.

I couldn’t, though. He was too fast. I spent minutes amazed that my own programming creation had escaped my power, trying to click on him and watching him get away. Every programmer has had a program run out of control, infinite loop, too-deep recursion, too-fast memory leak, whatever. It happens. But there was a uniquely personal quality to having programmed a little critter to try to get away from you and being unable to catch it because it could move faster than you could click the mouse on it.

Goober dragged a pen behind him so he left a record of his attempts to escape my right-click (screenshot).

IT’S ALIVE!!!

I eventually got it to stop somehow. I don’t even remember how. And I kept on programming. It was a lot of fun. But I’ve never had a programming experience quite so visceral as chasing Goober across the squeak screen as he evaded my every move. Very cool.

Squeaky Time!

I think I’m starting to understand how to play with Squeak’s eToys environment. It helped to explore it with a five year old by my side.

In this environment, you give objects “scripts.” Scripts can contain primitive commands like “move forward 5” or “make a squeaking noise,” or tests like “Is ___ true? If so, __ if not __”, or even other scripts. Yep, it’s just like programming. Objects can tell if they’re overlapping other objects or other parts of their environment. Oh yeah — when I say “objects” I’m not just talking about abstract programming objects — one way to create a new object is to draw it with a pen. Another is to pull it out of a box, a box with rectangles and stars and other things. Once you’ve got an object you can give it a name and add scripts to it. Besides adding scripts you can manipulate it directly by grabbing it, dragging it around, resizing it, recoloring it, turning it sideways, whatever.

Oh, and the scripts — you can see them. They’re little boxes and you add commands to them not by typing, but by dragging little tiles onto the box. It’s amazingly easy.

A script can be “ticking,” which means it fires repeatedly until you stop it. It can also be stopped. Objects can turn their own or other objects’ scripts on or off.

By the time things started getting interesting, this is what was going on —

We had a little alien face made out of a little drawing my son had made with some eyes added to it. The alien had some scripts we’d written, like “crawl” which sent it forward slowly, and “move warble and turn” which sent it backwards a bit, made it turn, and made it make a warbling noise.

I at first had the idea of making a box which could clone the alien face, but I didn’t quite know how to do that… So I made a box which could tell if an alien was touching it, and turn blue if that was the case, and red if it wasn’t. OK, that was cool. But it was cooler when in addition to making it turn blue, it told the alien face to “move warble and turn.”

Now you could make the alien face crawl at the box, and when it hit, the box would flash blue and the alien would warble, turn, and back up — and then the crawl could keep going.

Then I made four copies of the box, and was happy to see they all had the same power of making the alien warble! I elongated them and made a cage out of them, and let the alien face bounce around inside back and forth. Twas cool. I made the alien face smaller so it didn’t hit so often, and could spend more time crawling, not constantly bouncing.

Before all this I’d drawn a little mouse and not done anything with it. I picked it up and started scripting it. First I called it “SketchMouse” but by this time my daughter had showed up and insisted it should be called “StickMouse,” so Stickmouse it was. I gave Stickmouse a script called “run” and made the stickmouse check to see if it was touching an alien, and if so, it would turn the StickMouse’s “run” script to “ticking” — and it would keep running until it wasn’t touching an alien anymore. I added a squeak to the mix; a mouse in Squeak should squeak!

Now the alien would run around bouncing off the walls, and when it happened to hit a mouse the mouse would squeak and wiggle out of the way.

Then I started cloning off a half dozen new Stickmice and let the fun begin!

What I took away from all this is that eToys isn’t about showing up with an idea of what you want to do and finding the tools to do it. It’s about building cool little things and seeing what happens when you tweak them and throw them at each other — seeing what emerges, that you would have never thought of before.

In retrospect I can also see much more effective ways I could have done things. First off, it was kind of silly to have all those paranoiac boxes waiting for an alien to show up so they could make it do a silly dance. Why couldn’t I just make the alien watch for boxes while it’s moving, and do its silly dance when it hits one? Then I’d have one entity “active” instead of a bunch of them.

Same thing with the mice — they were all watching out for that alien. Why couldn’t the alien have, say, triggered their “run away” script when it touched them, and then the “run away” script would itself have checked to see whether they’d escaped it and turned itself off when it was satisfied it had? Things like that.

And it’s all gloriously useless. It’s pure fun.

Stylin’

The problem with the wordpress default theme is that it’s insanely complicated, especially in the header area.  Someone going in to edit it a bit “starting with the default” is in for a world of hurt, because it’s many many many many lines of CSS.

Inspired by this post a weekend ago, I ripped the guts out of the default theme and created a “minimal” theme with no css at all.  I intended to go in and recreate it as a thing of beauty, but I hadn’t the energy at the time.

I just got some energy, I guess, because I just opened up “minimal” again and added a very small amount of css to it and it’s starting to look nice again.  Things I’d still like to do as I write: pick a less garish color for links, since there are so many of them; unsquish the text on the right a bit; stuff like that.  Any other suggestions?  Any browsers it looks downright *awful* on?

The Scariest Guy in Town

TIME.com: The Scariest Guy in Town — Dec. 4, 2006 — Page 1:

As the new chairman of the House Government Reform Committee, Waxman will have free rein to investigate, as he puts it, “everything that the government is involved with.” And the funny thing is, Waxman can thank the Republicans for the unique set of levers he will hold. Under a rules change they put through in the days when they used the panel to make Bill Clinton’s life miserable, the leader of Government Reform is the only chairman who can issue subpoenas without a committee vote. […]

Waxman likes to point out that the House took 140 hours of sworn testimony to get to the bottom of whether Clinton had misused the White House Christmas-card list for political purposes, but only 12 hours on prisoner abuse at Abu Ghraib.

Revenge against the Republicans would not be useful — it’d be sinking to, well, I won’t say “their level” as if viciousness were an inherent Republican trait; let’s just say the level they’ve preferred to play at for the last decade or two. But besides revenge there is reform. Investigation can punish, but it can also bring truth and clarity, and raise standards and level playing fields. There can be Nuremburg Trials, and Truth and Reconciliation Commissions. Let’s hope for the latter.

Ben Stein: Warren Buffet, Taxes, The Economy

In Class Warfare, Guess Which Class Is Winning – New York Times:

Mr. Buffett compiled a data sheet of the men and women who work in his office. He had each of them make a fraction; the numerator was how much they paid in federal income tax and in payroll taxes for Social Security and Medicare, and the denominator was their taxable income. The people in his office were mostly secretaries and clerks, though not all.

It turned out that Mr. Buffett, with immense income from dividends and capital gains, paid far, far less as a fraction of his income than the secretaries or the clerks or anyone else in his office. Further, in conversation it came up that Mr. Buffett doesn’t use any tax planning at all. He just pays as the Internal Revenue Code requires. “How can this be fair?” he asked of how little he pays relative to his employees. “How can this be right?”

Even though I agreed with him, I warned that whenever someone tried to raise the issue, he or she was accused of fomenting class warfare.

“There’s class warfare, all right,” Mr. Buffett said, “but it’s my class, the rich class, that’s making war, and we’re winning.”

Some really interesting writing from Ben Stein. Now that Republicans are allowed to break ranks and say what they think, it turns out a lot of them think things you didn’t think Republicans thought anymore.