Thursday, July 22, 2010

Voltorb Flip – Solver

About half of the Voltorb Flip Solver is.. well, the solver. When you get down to it, the Solver follows a very simple idea: it tries every permutation with every different state of every tile until it’s tried them all. The basic algorithm is as follows:
  1. Find the first empty tile (left-right, top-down, start at top-left)
  2. If none are found, you’re done; otherwise, continue to step 3.
  3. Pretend the tile’s a voltorb
  4. Try and solve the rest of the board
  5. If the rest of the board was solved, add the solution to our list of possible solutions
  6. If the rest of the board was unsolvable, ignore it
  7. Repeat step 3 for all possible tile states (voltorb, 1, 2, and 3)
That’s basically it. You’ll notice that this algorithm is recursive, that is, the function contains itself (step 4).
As for steps 5 and 6, when I say the board was solved, I mean it was solved correctly; that is, all the rows and columns added up to what they should have, and contained all the voltorbs they should have.
So that’s it! I’ll post again shortly, detailing some of the optimizations I made in the above algorithm, and the recommendation algorithm.

No comments:

Post a Comment