- Jinhong Lin
- Dianzheng Yu
C 4
T 5 7 1 2 0 9 3 4 13 8 6 11 14 15 10 12
I ingo.ppm
W ingo_scrambled.ppm ingo_scrambled.txt
S l
S u
S l
...
S u
W ingo_solved.ppm ingo_solved.txt
This input configures the puzzle, specifies the background image, performs a series of moves, and saves the initial and final configurations.
The executable for the program should be named "puzzle."
If invoked without command line arguments:
./puzzle
The program reads commands from stdin.
If invoked with a single argument:
./puzzle input.txt
The program reads commands from the file named by the command line argument.
C size
: Create an initial puzzle withsize
rows and columns.T tile...
: Initialize the puzzle configuration with a series of tile numbers.I filename
: Load the background image from the specified PPM file.P
: Print the sequence of tile numbers reflecting the current puzzle configuration.W filename1 filename2
: Write the puzzle image tofilename1
and the puzzle configuration tofilename2
.S direction
: Slide a free tile in the specified direction.K
: Check whether the puzzle is in the "winning" configuration.V
: Compute a series of moves to solve the puzzle.Q
: Quit the program.
The files test01.txt
through test09.txt
are example inputs. Corresponding example outputs, generated image files, and generated puzzle configuration files are found in the "expected" directory. You can run the puzzle executable on the example inputs and compare the generated outputs to the expected files using commands like diff
and compare
.
Example:
$ ./puzzle test06.txt > test06_out.txt
$ diff expected/test06_out.txt test06_out.txt
$ compare expected/ingo_scrambled_test06.ppm ingo_scrambled_test06.ppm \
ingo_scrambled_test06_diff.png
$ diff expected/ingo_scrambled_test06.txt ingo_scrambled_test06.txt
$ compare expected/ingo_solved_test06.ppm ingo_solved_test06.ppm \
ingo_solved_test06_diff.ppm
$ diff expected/ingo_solved_test06.txt ingo_solved_test06.txt
Feel free to explore and test the Puzzle Solver using different inputs!