Archive for category Bäume

Six of Clubs: Birthday Monduckenen-duckenen


First, check out Vi Hart‘s video about the Thanksgiving turduckenen-duckenen:

Now have a look at Mike Phirman‘s song, Chicken Monkey Duck:

Okay, there are monkeys instead of turkeys, and the mathematics isn’t quite as explicit, but it’s pretty similar, don’t you think? Now, let’s imagine that Mike Phirman is actually singing the recipe for a fractal turducken, or rather, monducken. You can imagine all the monkeys are turkeys if you’d rather eat the result than present it to some pretty thing to please them. (Note: Please do not kill any actual monkeys.) Monkeys, like birds, belong in trees, so I wrote an AppleScript to draw binary trees in OmniGraffle based on the text of the song. You can try it for yourself if you like; all you need is a Mac, OmniGraffle, and a text file containing some words. See the bottom of this post for links and instructions.

If Mike’s reading the binary tree recipe layer by layer, like the first example in Vi’s video, one possible tree for the first stanza of Chicken Monkey Duck looks like this, where the orange ovals are monkeys, blue hexagons are chickens and green clouds are ducks. You can click it (or any other diagram in this post) for a scalable pdf version where you can read the words:

First stanza breadth-first tree

I added numbers so you can easily tell the chickens, monkeys and ducks apart and see which way to read the tree. It’s simple enough now, but the numbers will be useful for reading later trees which are not in such a natural reading order. This is called a breadth-first traversal of the tree, in case you’re interested. Now, what do birds and monkeys do in trees? They nest! So I wrote another script that will take any tree-like diagram in OmniGraffle and draw what it would look like if the birds, monkeys, or whatever objects they happen to be (the drawing is pretty abstract) were nested inside each other, just like the quails inside the chickens inside the ducks inside the turkey. This is what the monducken described by the first stanza of Chicken Monkey Duck, in the tree structure shown above, would look like:

First stanza breadth-first tree nested

The Monducken script allows using a different shape for each animal as redundant coding for colourblind people, even though it already chooses colours which most colourblind people should be able to distinguish. But that makes the nested version look a little messy, so here’s the above diagram using only ovals:

First stanza breadth-first tree nested ovals only

If you named this particular recipe in the other way, going down the left side of the tree and then reading each branch in turn in what is known as a pre-order traversal, it would be called a Monenmonenduckduckmon-monmonducken-enenmonduckmon-enmonduck-enduckmonducken-enmonen-duckenenmon-monenmon. It doesn’t sound nearly as nice as Turduckenailailenailail-duckenailailenailail because Mike Phirman didn’t take care to always put smaller animals inside large ones. I’m not holding that against him, because he didn’t realise he was writing a recipe, and besides, it’s his birthday. For reasons I’m not sure I can adequately explain, it’s always his birthday.

But what if I completely misunderstood the song, and his recipe is already describing the fractal monducken as a pre-order traversal, always singing a bird or monkey immediately before the birds and monkeys inside it? Well, don’t worry, I added a ‘pre-order’ option to the script, so you can see what that would look like. Here’s the tree:


First stanza preorder tree

and here’s how the actual birds/monkeys would look if you cut them in some way that showed all the animals, dyed them the correct colours, and looked through something blurry (here’s the version with different shapes):

First stanza preorder tree nested ovals only

Okay, but that’s only the first stanza. What if we use the whole song? If we pretend the recipe is breadth-first, this just means all the extra monkeys and birds will be at the bottom levels of the tree, so the outer few layers of our monducken will be the same, but they’ll have a whole lot of other things inside them:

Entire song breadth-first

Entire song breadth-first nested

Here’s a close-up. Isn’t it beautiful?

breadth-first close-up

If the entire song were treated as a pre-order monducken recipe, we’d still have the same monkey on the outside, but the rest would be quite different:

Entire song preorder

Entire song preorder nested

We could also read the birds and monkeys from left to right, as Vi did in her video. That’s what’s called an in-order tree traversal. But as delicious as they are mathematically, none of these orderings make much sense from a culinary perspective. Even if the monkeys were turkeys, it’s obvious that a nice big goose should be the outer bird. Vi suggested that herself. Of course, we could put the goose on the outside simply by reversing the song so it started with goose. But it would be much more fun and practical to pretend that Mike is naming the two inner birds before the one that contains them. This is called a post-order traversal, because you name the containing bird after the two birds or monkeys it will contain. It makes sense for a recipe. First you prepare a monkey (or turkey) and a chicken, then you immediately prepare a chicken and put them into it. You don’t have your workspace taken up with a whole lot of deboned birds you’re not ready to put anything into yet. Here’s one way the recipe could be done:

entire song postorder

Note that no matter what kind of traversal we use, there are actually several ways the recipe could be interpreted. If Mike says ‘monkey chicken chicken’ you know you should take a monkey and a chicken and put them in a chicken. But if the next words are ‘monkey chicken’, do you take that stuffed chicken and a monkey and put them inside a chicken? Do you debone the monkey and the chicken and wait for the next bird to find out what to put them into? What if there’s no next bird? What if there’s only one more bird (let’s say a duck) and you end up with a stuffed chicken, a stuffed duck, and nothing to stuff them into? You’d have to throw one of them out, because obviously your oven only has room for one monducken. Assuming you want two things in each thing, and you don’t know how long the song’s going to be, the best way to minimise this kind of problem is to always take your latest stuffed thing and the next, unstuffed thing, and put them inside the thing after that. The worst that’ll happen is you’ll have to throw out one unstuffed bird or monkey. But then you end up with a really unbalanced monducken, with a whole lot of layers in one part and lonely debonely birdies floating around in the rest.

It helps to have a robot chef on hand to figure out how many full layers of monducken you can make without it being too asymmetric. Mine makes the trees completely balanced as deeply as possible, and then does whatever was easiest to program with the remaining birds and monkeys. In this case it was easiest for my program to stuff a whole lot of extra animals into that one monkey on the left. This is what it looks like, with the varied shapes this time. Luckily, geese are rectangular, so they fill your oven quite efficiently:

entire song postorder nested

I like how you can see the explosion of duck radiating out from the inner left, engulfing all the other birds and monkeys before itself being swallowed by a goose. Such is life.

IFIf you would like to make diagrams like this yourself, there are two AppleScripts you can use. Both of them require OmniGraffle 5 for Mac, and if you want to make trees with more than 20 nodes you’ll probably need to register OmniGraffle.

The first is Monducken diagrammer, which you can download either as a standalone application (best if you don’t know what AppleScript is) or source code (if you want to tweak and critique my algorithms, or change it to use OmniGraffle Professional 5 instead of OmniGraffle 5.) Because it’s AppleScript, it works by telling other applications what to do, rather than doing things itself. So when you run it, TextEdit will ask you to open the text file you want to turn into a tree. Once you’ve opened one, OmniGraffle will start up (you may need to create a new document if it’s just started up) and ask you two things. First it will ask what kind of tree traversal the text file represents. Then it will ask you what kinds of shapes you want to use in your tree. You can select several shapes using the shift and command keys, just as you would for selecting multiple of just about anything on your Mac. Then you can sit back and watch as it creates some shapes and turns them into a tree.

The other one is Tree nester (standalone application/source code) You should have an OmniGraffle document open with a tree-like diagram in it (I suggest a tree generated using Monducken diagrammer; it has not been tested on anything else, and will probably just duplicate most of the shapes that aren’t trees or end up in an infinite loop if there’s a loopy tree) before you run this. It won’t ask any questions; it’ll just create a new layer in the front OmniGraffle document and draw nested versions of any trees into that layer.

If you’re looking at the source code, please bear in mind that I wrote most of this while on a train to Cologne last weekend, based on some code I wrote a while ago to draw other silly diagrams, and I really only dabble in AppleScript, and I forgot about the ‘outgoing lines’ and ‘incoming lines’ properties until I’d almost finished, so it probably isn’t the best quality AppleScript code. Not the worst either though. I welcome any tips.

, , , , , , , , , , , , , , ,

1 Comment

King of Spades (Moxy Früvous parody)


This is a parody of King of Spain by Moxy Früvous, written by me and sung by my not-so-top-secret collaborator, whom some of you recognised as Hello, The Future! She was sick for a while, which is why this is a week later than promised. There’s an mp3, but it probably makes more sense with the video.

Here are the lyrics (forgive the spacing; if I could have a superpower, it would be to always be able to make WordPress space lines the way I want):

Once I was the King of Spades              now I’m just a playing card

Oh, how I planted that naked lady          now I’m just a playing card

I’m telling you I was the King of Spades   now I’m just a playing card

And now it takes lady luck to play me

Wan, 2 3 4!

Chicks dug me, spades really suited me

digging up bones from the late Cretaceous or planting downy birch trees

Now I eat humble pie whenever the ace is high

Caught in a flush for a poker cheater, plotting to crush the other guy

Once I was the King of Spades             now I’m just a playing card

A pirate’s deckhand, burying lucre        now I’m just a playing card

I’m telling you I was the King of Spades  now I’m just a playing card

And now my hand sweeps the deck at Euchre

Once this was the King of Spades

Folks would rave, they’d die so I’d dig their grave, the people said:

“King, how are you such a genius?”

“Your mounds are convex”

“and holes are concave!”

Kill chafer grubs so I would have safer shrubs

I’d do yardwork all through the weekend

and dig diamonds to give the lonely hearts clubs

Once I was the King of Spades                             now I’m just a playing card

Old tree falls, new sea walls, you sat back, I’d hack that.   now I’m just a playing card

I’m telling you I was the King of Spades                     now I’m just a playing card

Now the Ace hits me up to save you at blackjack.

Once this was the King of Spades

Ladies and Gentlemen, make your bids for the instrumental bridge!

Now some of you might be wondering how I came to be a playing card

after being a real life king of spades. Should I lay my cards on the table?

(shouting)

Deal me in!

You see late one day, I’d just dug a wishing well

Clearly I had to test it, I’ve pride in the service I sell.

And I thought, well this number’s fun, but I should be in the pictures

Next thing my heads are pounding, I’m upside down,

and I’m too legless for britches.

Ship and flatfish, banquet and cat dish

How I wish I’d never made that wish.

Counter to all intentions, I only have two dimensions.

If you’ve felt you’re bored with the cards life dealt

Remember, real life beats royal flushes

so dig your way to gold rushes!

Once I was the King of Spades                      now I’m just a playing card

I was dealing out gem stones from pyroclastic      now I’m just a playing card

I’m telling you I was the King of Spades           now I’m just a playing card

And now my dealer is Angelastic.

Once this was the King of Spades

It was obvious I should parody this song for the King of Spades. I assumed I’d end up writing a nonsense song describing all the Kings of Spades I have in rhyme, and that it wouldn’t make any sense at all without a video showing the cards. Sort of like Jonathan Coulton’s Flickr. But to make a video, I’d need someone to sing it. Naturally, I thought of Hello, The Future! since she has already written one King of Spain parody, and when I first met her she was wearing a ‘Hello, The Future! is the name of my Moxy Früvous cover band’ T-shirt. Also, I knew she had a fez and had experience wearing a fake moustache. I commissioned her to do it even before I’d written anything. Once the lyrics were written, I sent her my shouting parts, some noises I made with my rainstick (which I am determined to use in everything now) and a plastic box full of kings of spades, and the one line which I realised, to my horror, would only make sense if I sang it myself, and she mixed it all in. It ended up being some kind of story about a real-life spade maven who turns into a playing card, and it might make some kind of sense without the video, but it’s still more fun with it.

One thing I hoped I could make clear in the video was that the ‘naked lady’ line was referring to amaryllis bulbs; I’m not sure how widespread that name is. But alas, amaryllis is out of season here.

One of these days, I should put this and several other things on my podcast. Unfortunately, I chose a podcast hosting platform which is a real hassle to use, so I’ve been lax in adding things to it.

I used cards from several new decks of cards this week. Obi-Wan Kenobi from a Star Wars Heroes & Villains deck I got in Sweden made an appearance (he’s a King of Spades, but was the ‘Wan’ as I shouted ‘1 2 3 4’), as did a Queen of Hearts (in the lonely hearts club) from the Vasa Museum in Stockholm. Also in the lonely hearts club is a King of Spades from a Kama Sutra deck I found while searching for panties to throw at Paul and Storm. Underneath the ship card, you can see some information from a Golden Gate Bridge deck I was given on JoCo Cruise Crazy 2, and somewhere in there is a King of Spades from a pirate deck I bought in Aruba (the same place I got the rainstick) during that cruise.

, , , , ,

1 Comment

Ten of Spades: The Story of the Three Bears


Once upon a time there were three bears; a mummy bear, a daddy bear and a baby bear. After they had finished their porridge one evening, it was time for Baby Bear to go to bed. So Mummy Bear tucked Baby Bear in and gave him a kiss goodnight, and then Daddy Bear started to tell him a story.

Once upon a time, there were three humans: a mummy human and the two human cubs she’d had the previous winter. One day, while they were out looking for some fruit for the winter, a young bear found their den and went inside. He could smell delicious trash and blackberries, and soon found three piles of it on the floor. He tasted the first one, but it was too trashy. He tasted the second one, but it was too sweet. Then he tasted the third one, and it was just right, so he ate it all up. He looked around and found some fruit, but it was too fermented and didn’t taste good. Then he found a pile of leaves. He was so sleepy after eating so much that he lay down in the pile of leaves and went to sleep.

When the human family came home, they could smell that something was different.

“Somebody’s been eating my garbage!” huffed Mummy Human.

“Somebody’s been eating my garbage too!” moaned Girl Human

“Somebody’s been eating my garbage, and they’ve eaten it all up!” barked Boy Human.

The three humans sniffed around the den, trying to find the culprit.

“The garbage smells like bear!” huffed Mummy Human.

“The fruit smells like bear!” moaned Girl Human.

“The leaves smell like bear, and there’s a bear here!” barked Boy Human.

The excited barking of the human cub woke up the bear, who jumped up and ran away as quickly as he could. And the humans never saw the bear again.

Baby Bear went to sleep, happily clutching his teddy human.

A few weeks later, when the family came home from their walk and Baby Bear found a human girl in his bed, Baby Bear decided to let it sleep there for the rest of the winter and maybe have babies. He didn’t tell his parents, and went to find some fermented fruit to put next to the bed. When he came back, he tripped and fell, and the human woke up, screamed, jumped out the window and ran away. Baby Bear cried and cried and cried. His parents heard his crying, and scolded him for trying to keep the human a secret. They explained that real humans weren’t like the ones in the story, and they had guns that could kill baby bears like him, so he should never try to be friends with one.

Baby Bear cried and cried and cried and cried.

Read the rest of this entry »

, , , , ,

Leave a comment

Seven of Diamonds: The Tree


tree500As autumn comes I breathe your sanguine red
and tremble at the falling of each leaf.
I’ve wasted nights just sobbing on your bed
of leaves, and vow to fight impending grief.
I wrap you, still alive, to stop the shed,
your shield against the winter, metal leaf.
In spring, I take the helmet from your head,
its aventail a shroud upon the dead.

 

Read the rest of this entry »

, , , , , , , ,

4 Comments

Eight of Diamonds: The Village of Silver


Although many stories end up coming full circle, the first step is always finding a few good lines to lead into it. The steps are too steep for me to climb, I will wait and watch.

All the best pictures have canoes in them. As the boat left the wharf, they did not know that they would soon be the first victims of the biggest eruption in history. They used the clock tower to localise themselves in time and space. The people did not know that the tower would soon fall. It was big.

The butterfly said, “Some creatures are bigger than they have any right to be. The problem with rankings is that the first and second always crowd out the third. I am not going to react to that in the way you expect.”

The butterfly does not know what you have called him, he just lives.

The frog said, “I know a man who collects frogs. Hair brushed back to impress you, he has addled your brains, you no can no longer call yourselves human.

Why do you keep calling me a bull? I don’t wear armour and spikes to threaten you, but to protect myself. Standing on the stump of what was my home, I can’t help but wonder if there is any more of a future for those who destroyed it. After all their adventures, one diamond is still missing.”

A line of spikes separated the riches from the untamed sea. Many colours, reaching to the sky. Each stalk is topped with a permanent snowball. Scientists rushed to tend to the glowing backbone. The crowd rejoiced as they saw their work fall away.

Their neighbour was richer than they thought. A giant living diamond thrashed its way forward through the sea. A single female to perpetuate the genes of a thousand men.

And a gold-crazed fool said, “This is no more possible than a flower growing from another flower. I sent e-kisses over the internet before my first real kiss. I have two pillows, but there is no room for another in this bed.”

The trick in gathering treasure is to leave room for more. They got on like two flowers in a pod.

A village of silver, covered in white snow, one lasts and the other is precious.

 

Rearranging the components of your point does not make it any sharper.

Read the rest of this entry »

, , , , , , , , ,

1 Comment

%d bloggers like this: