Monthly Archives: October 2010

Alchemy

(WARNING: spoilers ahead!)

Alchemy is a fun little grind game for Android. The premise is simple. You start with four elements: earth, air, fire, and water. You can drag any element onto any other, and they might “combine” to make one or more new elements. For example, dragging earth onto air makes dust. You can then drag dust onto water to make mud. Things start getting really funny as elements get more complex (e.g. dragging man onto beer makes an alcoholic, which is useless for further combinations. Lulz.) The combinations are often surprising and amusing… until you realize it’s a grind game, and you’re not finished until you find all 300 combinations. There is some very amusing logic to the game, and some of the combinations are downright hilarious… But this kind of game just can’t keep my attention if all one does is grind.

The killjoys among us could just go to any number of cheat sites and download the recipe for every possible element. But even if you wanted to just blow through every element, it’s not that easy: “Okay, I want to make Twilight Saga, so I need a vampire, which is made of blood, which is made from a beast, wait, how do I make the lizard prerequisite again??!?” Obviously, if you’re going to cheat, you really want a cookbook that reduces each element to its most primal form: some combination of earth, air, fire, and water. But how to generate such a list?

Finally, the game got interesting for me. Here’s a perl script that takes the master list of elements from the above cheat site, and turns it into entries like:

lizard : ( ( earth + water ) + ( earth + ( ( ( ( air + fire ) + ( earth + water ) ) + ( earth + water ) ) + water ) ) ) + ( earth + ( ( ( ( air + fire ) + ( earth + water ) ) + ( earth + water ) ) + water ) )

…or even:

mcdonald’s : ( ( ( ( water + ( ( air + fire ) + ( fire + ( air + ( earth + fire ) ) ) ) ) + ( ( earth + ( ( ( earth + water ) + ( earth + ( ( ( ( air + fire ) + ( earth + water ) ) + ( earth + water ) ) + water ) ) ) + ( earth + ( ( ( ( air + fire ) + ( earth + water ) ) + ( earth + water ) ) + water ) ) ) ) + ( ( air + fire ) + ( earth + water ) ) ) ) + water ) + ( ( ( ( ( ( air + ( earth + fire ) ) + water ) + ( ( air + ( earth + fire ) ) + water ) ) + ( earth + ( ( ( air + fire ) + ( earth + water ) ) + ( ( air + ( earth + fire ) ) + water ) ) ) ) + ( earth + ( earth + ( ( ( ( air + fire ) + ( earth + water ) ) + ( earth + water ) ) + water ) ) ) ) + fire ) ) + ( ( ( earth + ( ( ( earth + water ) + ( earth + ( ( ( ( air + fire ) + ( earth + water ) ) + ( earth + water ) ) + water ) ) ) + ( earth + ( ( ( ( air + fire ) + ( earth + water ) ) + ( earth + water ) ) + water ) ) ) ) + ( ( ( fire + ( air + ( earth + fire ) ) ) + ( ( ( earth + ( ( ( earth + water ) + ( earth + ( ( ( ( air + fire ) + ( earth + water ) ) + ( earth + water ) ) + water ) ) ) + ( earth + ( ( ( ( air + fire ) + ( earth + water ) ) + ( earth + water ) ) + water ) ) ) ) + ( ( air + fire ) + ( earth + water ) ) ) + ( fire + ( air + ( earth + fire ) ) ) ) ) + ( ( earth + ( ( ( earth + water ) + ( earth + ( ( ( ( air + fire ) + ( earth + water ) ) + ( earth + water ) ) + water ) ) ) + ( earth + ( ( ( ( air + fire ) + ( earth + water ) ) + ( earth + water ) ) + water ) ) ) ) + ( ( air + fire ) + ( earth + water ) ) ) ) ) + ( ( ( ( air + ( earth + fire ) ) + ( ( earth + ( ( ( earth + ( ( ( earth + water ) + ( earth + ( ( ( ( air + fire ) + ( earth + water ) ) + ( earth + water ) ) + water ) ) ) + ( earth + ( ( ( ( air + fire ) + ( earth + water ) ) + ( earth + water ) ) + water ) ) ) ) + ( ( air + fire ) + ( earth + water ) ) ) + ( fire + ( air + ( earth + fire ) ) ) ) ) + ( ( ( air + fire ) + ( earth + water ) ) + ( ( air + ( earth + fire ) ) + water ) ) ) ) + water ) + fire ) )

See? Simple. The perl code is actually simpler than the resulting recipe, thanks to the power of recursion!

Since I don’t want to spoil the game for everybody, I won’t post all of the recipes here. ;)

#!/usr/bin/perl -w
sub lookup {
  my $s = shift;

  if($element{$s}[1]) {
    return "( " . lookup($element{$s}[0]) . " + " . lookup($element{$s}[1]) . " )";
  }
  return $s;
}

while(<>) {
  /(.*) = (.*) + (.*)$/;
  $element{$1} = [$2, $3];
}

for my $el (sort(keys(%element))) {
  $simplified{$el} = lookup($element{$el}[0]) . " + " . lookup($element{$el}[1]);
}

for(sort(keys(%simplified))) {
  print "$_ : $simplified{$_}n";
}

Tune in next week for my exciting python script that solves Super Mario 3

Cell Phone Spectrometer

(or, A Guided Inquiry Approach to Teaching How to Think About Analytical Instrumentation.Wired has a great article about a scientist at the University of Illinois / Urbana-Champaign who published software and plans for turning a cell phone camera into a simple DIY spectrometer.

The camera simply takes a photo, and the resulting JPEG is analyzed by a Windows program. The software and source are available under Creative Commons on the project’s website.

“Science is basically about using your senses to see things – it’s just that we’ve got so much technology that now it’s all hidden,” Scheeline said. “The student gets the impression that a measurement is something that goes on inside a box and it’s completely inaccessible, not understandable – the purview of expert engineers.”

“In order to get across the idea, ‘I can do it, and I can see it, and I can understand it,’ they’ve got to build the instrument themselves,” he added.

This is a fantastic example of how to encourage people to learn by taking a complex idea and breaking it into simple (and fun!) to reproduce steps.