A familiar tile puzzle from a larger “Escape the Room” project.
This was a very enjoyable project for me and is a part of a much larger fun project that I decided to start working on which is one of those “Escape the Room” style of games.
This will be one of those puzzles you need to solve in order to successfully get out.
Many of you have probably seen one of those cheap plastic puzzles where you need to basically unscramble the numbers and have them all in the correct order.
This is done by sliding the tiles around until you have them all in the correct position.
Here is my rendition of the classic sliding tile puzzle.
Basic Theory of Operation
The project is made up of 17 variables. Sixteen of them are basically location variables to track which tile is in which spot in the grid. One additional variable is used to specifically track the one grid square that is currently open.
For each grid location – there are either two, three, or four blocks of code for each of the possible directions that a particular tile can slide based on its position in the grid. The block that executes depends on which grid square is currently open. Every tile slide also does a check for the correct solution which will reveal the prize.
Alternatives to this might be to replace the numbers with pieces of an image that need to be rearranged to construct the right picture or a series of numbers and math operators that need to be positioned so as to be correct.
Are there any applications for something like this that you can think of?
I would be interested to hear them.
Please leave any comments or questions that you might have.