Face time

I was thinking today how nice it felt yesterday to create an “as simple as possible” program to practice chess.

And I started thinking that it might be nice to apply the same philosophy to an animation system. What would be the simplest possible tool to let people easily create animated stories about characters and relationships?

So today I wrote a little program, just a sketch really, of what something like that might look like. Click on the image below to try it out.



Practicing chess

There are hundreds of programs on-line for playing chess. But this afternoon a friend told me that she couldn’t find any on-line program that does a very simple thing: She would like to play practice games, moving all the pieces herself, while trying different variations.

I asked her why she doesn’t just use a real chess set. She told me that she can’t accurately remember all of the moves she’s made, so with a real chess set she couldn’t go forward and backward through her game.

It seems silly that there is nothing like that on-line (well, maybe there is, but neither she nor I could find it). So I told her I’d just write a little program to get the job done.

It wasn’t so hard because my program doesn’t actually need to know the rules of chess — my friend already knows the rules of chess. So the program is perfectly happy to let you make illegal moves. It really doesn’t care.

But whatever moves you make, the program lets you go forward and backward through your game to revisit your own game play, which is all my friend really wants. Besides, writing it was fun. 🙂

Click on the image below if you’d like to try out my rather minimalist chess practice program:



Prime directive

I was quite excited at the prospect that 2011 might be a prime number. I happened to be at my computer, but not on the internet, so I wrote a little computer program to run through the factors of 2011. If a number has no factors other than itself and 1, then it is prime.

Sure enough, my program told me that 2011 is indeed a prime year. Yay!

Of course the moment I got on-line, I could just Google it, using 2011 and prime as the search words. Sure enough, 2011 pops up on the very first hit (Wikipedia’s list of the first 1000 prime numbers).

The program was very simple (it took maybe 30 seconds to write), but I find it sad that I can’t easily share my joy of discovery, since unless you already know Java, the code I wrote will look to you like gobbledygook:

    for (int i = 1 ; i <= 2011 ; i++)        if (2011 % i == 0)            System.out.println(i);

If I translate this into a friendlier looking programming language, it might look like this:

    for every I from 1 through 2011
       if 2011 mod I is 0
          print I

That’s almost ok, except that people who don’t already know programming will get stuck at that second line. So let’s replace it with something even friendlier:

    for every I from 1 through 2011
       if 2011 is divisible by I
          print I

Ah, that’s more like it! Meanwhile, if you’re a more advanced programmer, you can peek to see how the computer is told what “is divisible by” means, again in this friendly computer language:

    A is divisible by B means
       the remainder of A divided by B is 0

Now we have something that anybody reading this blog can understand. And in my mind that was actually the program I wrote — except that as I typed the program, I automatically changed it into Java programming, sort of the way a pianist might transpose music from one key to another.

Maybe it would be a good idea to make it very easy to create these sorts of conversational programming Mad Libs (such as: “for every — from — to — ” or “the remainder of — divided by — “). Then it would be easy to write a program that anybody at all could read (or maybe even write), but which would still run on a computer.

Maybe we should hurry up and do that, while it’s still a prime numbered year. 🙂

Response to “A Mathematician’s Lament”

A poem in response to Paul Lockhart’s “A Mathematician’s Lament”, inspired by the mathematical doodles of Vi Hart.


Inside a box a triangle sits,
Somewhere, perhaps in your mind’s eye,
Wide as the box, and just as high.
In short, the triangle barely fits.

t0

What will the triangle’s area be?
A quarter of the box? Or maybe a third?
More than the box? No, that’s absurd.
Hmm, there’s a game here, you can see.

t1

A curious game — but how to play?
Maybe you should draw a line.
To split the triangle, that looks fine,
From top to bottom, all the way.

t2

Now two boxes sit astride
Where there had only been just one.
Twice the shapes means twice the fun!
And each contains more shapes inside.

t2b

The leftmost box is cut in half –
A line is slicing it in two.
Now equal shapes jump out at you.
It’s enough to make you laugh.

t3

For on the right it’s just the same.
Your triangle, you can say with pride,
Takes half the box’s space inside.
It seems that you have won the game!

t4

Candies all the way down

One problem with musical candy buttons is that sooner or later you run out of space to put all of the notes. Or, if you’re hungry, you might run out of notes altogether. Imagine you’re right in the middle of composing a delicious symphony in the key of Grape (I mean, um, in the key of B flat), and suddenly you run out candy buttons — or worse, you even run out places to put your candy buttons.

Never fear, there is a way out. In honor of the late, great Benoit Mandelbrot, I hereby introduce fractal musical candy buttons! I don’t have an interactive Java applet ready for you to play with quite yet. My eventual plan is to give you a way to zoom in and out, and otherwise navigate through the fractal score.

But I can show you a visualization of how such a space might look. Around the central tonic pitch (Peach), I’ve arranged half sized candy buttons representing the other six notes in the same key. Around each of these are still smaller candy buttons, and so on, ad infinitum.

Once I implement a way to let you zoom into this space, then there will be infinite melodies for you to explore, in an endless variety of colorful (and tasty) musical possibilities.

But that will probably have to wait until next year. 🙂



Candy button musical space

I thought it would be nice to give you a way to create your own original candy button musical space — something between a musical score and a musical instrument.

I’ve also started decorating the candy buttons, because everybody knows that low notes and high notes taste quite different, and you wouldn’t want to eat the wrong note! Candy buttons in the second octave now have little hearts painted on them. Candy buttons in the third octave have little painted stars.

As you can see in the image below, the top and right edges are all the flavors in the key of C major. The left and bottom edges are all the flavors in the key of C# major.

But you can try it for yourself. Click on the image to link to the on-line Java applet:



Counterpoint

Xiao’s helpful comments have encouraged me to iterate yesterday’s design. Rather than using words in the buttons of the latest little candy button music machine, I’ve adopted the philosophy of “less is more”, and have switched over to pictorial icons. This way the machine will be equally useful (or useless) everywhere in the world.

I also added a speed slider, so you can run the machine fast or slow or even backwards. As usual, you link to the applet by clicking on the image below.

Meanwhile, I’m thinking that making music with candy buttons would make for a very nice board game. The general idea might be that you have to play a melody to advance in the game — a kind of mash-up of Simon and Candy Land.



Rainbow fugue machine

Today I found myself in a bit of a fugue state, and it wasn’t all that bad. So I decided I would make a candy button machine to create fugue states.

Drawing inspiration from Xiao’s comment about the circle of fifths, I realized that if I could make a melody go around the entire circle of fifths, then my machine could use every candy button of the rainbow.

Coincidentally, today I reached page 152 in Vernor VInge’s novel Rainbows End. That’s the page where it is pointed out that the title of the book is actually a declarative sentence (and, when you think about it, a very sad sentence at that).

But in fact rainbows do not end, because rainbows are actually completely circular. Like Skittles.

So I decided to make a candy button rainbow fugue machine. In other words, a machine to generate never-ending fugues that go all around the circle of fifths, visiting every color of the rainbow on the way.

As you can see in the picture below, the machine has 12 spiral arms arranged around a circle (the circle of fifths, in fact). Each arm consists of the four notes of a dominant seventh chord in some random order, as candy buttons.

There are only two kinds of controls: less ↔ more to vary the number of voices, and thin ↔ wide to vary how far those voices spread around the circle of fifths.

It’s surprising how many musical variations you can get with just those controls. But don’t take my word for it. Try out the applet for yourself, by clicking on the image below:



Chasing rainbows

The 1917 song I’m Always Chasing Rainbows, by Harry Carroll and Joseph McCarthy, borrowed its melody from the middle section of Frédéric Chopin’s 1834 Fantaisie-Impromptu in C-sharp minor.

There have been many recordings of this wonderful song by everyone from Bing Crosby to Alice Cooper, but perhaps my favorite was the achingly sad rendition by Judy Garland in the 1941 film Zeigfeld Girl.

One of the things that intrigues me about the candy buttons representation of music is the way it blurs the distinction between musical score and musical instrument. I’ve transcribed the first few bars of I’m Always Chasing Rainbows onto a strip of candy buttons. The image below links to an applet that lets you play the song by moving your mouse across successive rows of candy buttons (it’s up to you to play with the correct rhythm).

Or you can roam your mouse freely over the applet, using the score as a kind of musical keyboard, to create your own melodies. The original melody you create will be a kind of collaboration between you, Harry Carroll and Frédéric Chopin.

Happy rainbow chasing!!!