Chris Pollett > Students > Hammoudeh
[Home] [Blog] |
Deliverable #1: Puzzle GeneratorJigsaw Puzzle Generator Source Code - zipThe first component needed to begin solving the jigsaw puzzle problem is the ability to parse a image and generate a board. The tool I developed is written in Python version 2.7.11. It uses the following libraries:
pip install .
Below is an example image of my cat Muffins:
By running the " puzzle.py " with default settings, the output will be as shown below:
A few things to notice:
Two additional supported features are below. They can be added individually or in tandem. Shuffling:Before solving a jigsaw puzzle, the first step is to randomly shuffle the pieces. This is done using the standard Fisher-Yates shuffling algorithm. To enable rotation, line #285 in file "puzzle.py" ("# test_puzzle.shuffle_pieces() ") should be uncommented. Below is the image with pieces shuffled only; notice for example, that the peppers are moved throughout the board.
Piece Rotation:In much of the previous work done on the jigsaw puzzle problem, rotation of tiles was disallowed. In my application, I plan to make selectable whether rotation is enabled or disabled. To enable rotation, line #48 in file "puzzle_piece.py" ("rotation_enabled = False ") should be changed to: rotation_enabled = True . Below is an image with rotation enabled (and shuffling disabled). Notice how the keys and utility knife remain in the bottom left corner but are rotated away from each other.
|