|
|
CSE143 Autumn 2004 Project #3 Part A The 15-puzzle game
|
1 | 2 | 3 | |
4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 |
For part A you will generate random initial orderings of the tiles, then allow the user to manipulate the tiles in the square in order to come up with a solution. In part B you will actually automate the solution finding process.
Work with your assigned partner. The same rules as always apply: try to do most of the actual coding while sitting at the same computer, trading off the keyboard. The two of you should turn in a single set of files. After the final part of the project is done, each of you will individually write a final report.
Grading: When the project is complete, your project will be evaluated both for how well the code works and how well it is written and tested. For this part of the project, we will try to give you quick feedback on the scale of 0-3: 3 = no major problems, 2 = something needs to be fixed, 1 = serious trouble, and 0 = no credible effort. For all phases of the project, be sure to include appropriate JavaDoc and other comments in your code, use meaningful names, indent sensibly, provide toString() methods where appropriate, and so forth.
Keep track of the major design decisions, algorithms, and tests you perform to verify your code is working. You will be asked to include a summary of these in the report that you will write individually at the end of the final part of this project.
The 15-puzzle is originally displayed with a random ordering of numbers 1 through 15 plus a blank (empty) square. The user then needs to move one square at a time until the numbers are ordered (or until the user gives up since these games don't always have a solution). A square can only be moved if there is an adjacent free slot to move to. A puzzle is said to be solved if the numbers are in increasing order and the empty slot is either in the top left corner (next to 1) or in the bottom right corner (next to 15)
Random
class java documentation to get ideas
about how to implement this. The user will then have to swap the empty
slot with a numbered slot one at a time using the mouse and, optionally,
the keyboard. Furthermore, an encouraging message should be displayed if
the user solves the game. This message should include the number of moves
it took for the user to complete the game.
The purpose of this part of the project is to get you more used to collections and their implementation and to practice graphical event driven interfaces one more time. Here are the requirements for your program:
ArrayList
and map each
cell to a corresponding row and column in the puzzle. You could also
implement
this using a bi-dimensional
array. You can choose any data structure as long as you use a Collection
to represent the puzzleAs usual, we invite you to use your imagination to extend the project in ways you find interesting. Here are a couple of ideas to get you started.
There's a lot of room in this project to be creative so have fun with it!
Use this turnin form to turn in the files that make up your program and tests.