Skip to content
Algorithm to solve the Amaze!!! Game
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore
README.md
amaze.py
cyto.json
graph.html
graph.png
index.html
screen1.png
screenshot.jpg

README.md

AmazeSolver

There is a pretty fun game called "Amaze!!!", iOS link, in which the premise is to cover a full game board with paint.

I have been playing it somewhat obsessively while traveling for the past few months (as seen by the fact that I'm on level 14073 - don't mind that, though, as the levels actually reset and wrap around to the beginning after a hundred or so, which was a disappoinment).

screenshot

I wanted to see if I could come up with an algorithm and representation of the game in Python.

Rules

You start as a ball placed on the grid. You can swipe in 4 directions - up, down, left and right.

You travel as far on the grid as possible in that direction. Below you can see the progression of 4 turns.

Initial board, a move right, a move up, and a move right.

initial game

The goal is to completely cover the board in paint.

The game itself is trivial (and in fact I wish it was harder, perhaps a limitation on the number of moves, or the amount of paint you can lay down, or a timer). So trivial, in fact, that I recreated it in javascript to play around with it. I adapted some of the code from here and made it a little more functional and changed it to Amaze!!!.

Goal

I wanted to see how easy it would be to build an AI that would A) solve the puzzle and B) see if I could find a way to actually find the optimal solution. The latter seems significantly more difficult than the former.

Note: After giving this some more thought I realized it's just a modification of the traveling salesman problem... What a bummer, to find out the problem you're trying to find an optimal solution to is NP hard.

We can model our moves as a directed graph. You can't actually stop at every position on the board. You can make each valid ending point a node, and the outgoing four cardinal directions can be the edges to other valid ending nodes.

It's still not clear to me if you have to visit every node, but you do have to visit (traverse over) every empty block. We might be able to abstract over this - since we know every level in the game is solvable, simply visiting all valid locations encompasses every valid path.

If a nodes final location is on the path of two other nodes, you don't need to visit that node, but you might have to visit that node to clear the blocks on that nodes path?

The graph for the first example is below. The node names are the indices of the board on a 2D array. The board is 13x13, and the starting position is (12,0)

graph

You can’t perform that action at this time.