# 15 Puzzle - sliding blocks

Click the sim once to enable it to respond to keyboard keys.
Click for playback controls and for sim info and reset.

Only two tile pictures are used (light and dark). Tile numbers are local character variables added in the paint window.

Pressing the space bar anytime will shuffle the pieces. The shuffle ring moves at random, in a similar fashion to a 'ladybug', ie it cannot move backward and so unshuffle the previous move.

The shuffle ring counts down each move to zero and then heads for the lower right corner before disappearing.

Tiles in the correct position light up and their number changes from grey to red.

A bit of maths determines if a tile should appear lit. The calculation is:
Tile No = 4*(4-V) + H
where V = vertical position of tile
and H = horizontal position of tile
(remember lower left position is 1,1).

Any piece in the same row or column as the space can be clicked, allowing several pieces to be moved at once, as in the real puzzle.

The background turns orange when the puzzle is correctly completed, -but only after at least one shuffle has been done.

Controls:

Space Bar -shuffle.

Mouse -click on tile to move.

Arrow Keys -move tiles (think of moving the empty space).