Alchemy

<img decoding=”async” loading=”lazy” class=”alignleft size-medium wp-image-382” title=”jzqni.u.cs.png” src=”uploads/2010/10/jzqni.u.cs_.png-168x300.jpg

(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


Alchemy
https://hackerfriendly.com/alchemy/
Author
rob
Posted on
October 15, 2010
Licensed under