Computer-Generated Zeppelin

facebooktwitterreddit

(Warning, severely geeky content follows.) Programmer Steven Frank, creator of Spamusement and Basketball 2, has done it again. His new zep.pl program uses the power of your computer to randomly combine a set of words, eventually creating the opening lyrics to Led Zeppelin's "Black Dog" after a number of iterations. Let's walk through the source code to understand how:

  1. The program is written in Perl, a popular scripting language. All Mac OS X computers include Perl, in case you want to run the program on your Mac.
  2. Start with a set of words: hey, mama, said, the, way, you, move, gonna, make, sweat, groove.
  3. Declare the goal state. We want the computer to come up with the sixteen-word phrase from "Black Dog": "hey hey mama said the way you move gonna make you sweat gonna make you groove."
  4. Randomly combine the words from step 2 to create sixteen-word phrases, printing each phrase as it is generated. As we slot in each word into its correct place in the goal state, save that word and just randomize the remaining words.
  5. Repeat until the goal state is achieved.
  6. After running for less than a second, we're done. The program prints: "Black Dog achieved in X ZepMarks," where X is the number of iterations from step 5. (Typically it happens in 20-60 ZepMarks.)

Behold, the power of randomness. (Programmers may enjoy the comments on Frank's zep.pl blog post, where people compare the lowest number of ZepMarks they have achieved, and even port the program into other languages.)