Open boxes and run away until there's no more reason to.
There's a bunch of notes in the code. They're largely for my benefit. Feel free to ignore them.
(First revision is still available at: http://www.puzzlescript.net/play.html?p=7c6f45d3fb68651f97577fe99ae3e6b5)