CS120, Fall 2007
Assignment #9
TARGET DATE: Monday, December 10.
This is the conclusion of the project begun in
Assignment 8
to create a Processing applet that
allows a user to solve the "eight puzzle" with a mouse, as illustrated
here.
You'll be starting with quite a bit of code, which can be found
(along with its behavior) on
this page. Besides
the files EightPuzzleFramework, EightPuzzle.java (a pared-down version of what you did in Assignment 8), PushBar.pde and Square.pde, you will also need the various fonts
indicated. We'll go over how to put all this together in
lab 7,
as well as how to proceed.
In the final lab of the semester, we'll also see how to convert this
to a real Java
applet and post it on a web-page (like in the links above).
This will be a straightforward
but fun part of the assignment; more detail to follow.
Now when you're done, you might find yourself wanting some further
challenges. There are a number of directions you can take here. Some ideas,
in roughly increasing order of difficulty
(none of which, I confess, have been implemented by me except
for the first):
- Simple cosmetic changes: Different colors, different fonts, etc.
- Put a nice border around the board; make it look more elegant.
- Also cosmetic, and I don't think too hard: Can you get the squares
to have a kind of (shallow) 3D look to them?
- Create a random start, rather than 8 down to 1.
(BUT, if you do this, please make it easy to modify the
program so that you can get the descending 8 down to 1 start. Or better yet,
make it a feature of the program to allow the user to choose
which kind of start they want. Perhaps two buttons, one for a random
start and one for a descending start.)
- Make some kind of fancy animation when the user wins.
For example, have the squares and fonts flashing to different colors,
or something else more celebratory. (And then, perhaps after a
certain amount of time, or when the
reset button is pushed, have it all return to peace and quiet.)
- Change it to a 15-puzzle. I.e., same exact idea but on a 4 X 4
board, with squares labeled from 1 to 15. (This will require
changing the EightPuzzle class to a
FifteenPuzzle class. Or, come to think of it,
can you see how to
generalize it to an N_Puzzle class?)
In this case too, I ask that you also hand in the 8-puzzle
version, since that will be a lot easier for me to test.
- Arrange it so that two squares (or 3, if you're doing the
15-puzzle) can move at a time. For
example, in the initial configuration, make it so that clicking on the 6
causes both the 6 and the 3 to move down, rather than outputting the
message that 6's square cannot be moved. I expect this to involve
changes to the underlying EightPuzzle class as well
as to the main program, and possibly to the Square
class (although I believe changes to the latter can be
avoided).
Back to CS 120 Home Page