A Solver for Puzzle Quest and Aurora Feint

Puzzle Quest and Aurora Feint are two very similar games. In both, you have to match three or more square blocks with the same color horizontally or vertically by exchanging two neighboring blocks. Those matched blocks are then eliminated from the board and the blocks above them fall down to take their place. Both games have special pre-built maps which challenge the player to clear all blocks. In Puzzle Quest the difficulty is that only moves which result in matched blocks are permitted, whereas Aurora Feint requires that the challenge be completed with a certain number of moves or less.

Being too lazy to think for myself I wrote a program to solve those maps for me. I have set up a public Mercurial repository for it at http://hg.13thfloor.at/hg/puzzlequest/.

Here’s how to solve an Aurora Feint puzzle with a maximum of two moves:

$ ./puzzlequest -a -d2 <af-puzzles/fall_rain.2
. . . . . .
. . . . . .
. . . . . .
. . . g . .
. . b g . .
. g b b . .
 
2,1 -> 3,1
 
. . . . . .
. . . . . .
. . . . . .
. . . g . .
. . g b . .
. g b b . .
 
3,0 -> 4,0
 
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .

Coordinates are given in the form column,row, with the lower left block as the origin (0,0).

The program is written in Haskell. It’s only my second program written in that language, and it shows: it’s neither elegant nor efficient. My first Haskell program was an interpreter of a small subset of Scheme, which I’ve made a point of implementing as the first thing in any new programming language I learn, a practice I can highly recommend. Here are interpreters I’ve written in Forth and O’Caml.

Advertisements