Due Saturday 1 November 1997
This assignment is 60 points of your overall grade.
Instant InsanityTM was a popular commercial puzzle of the 60's, before Rubik's Cube. Gradual InsanityTM is a puzzle, shown below and invented by your instructor, which is more akin to Rubik's Cube in its working than Instant Insanity. (The title is supposed to refer to the effect on the user, not the programmer.) This assignment involves implementing a portion of the Gradual Insanity puzzle as a JavaTM applet using object-oriented programming. Since the purpose is to learn about object-oriented programming, submissions must be object-oriented in a sense to be described in order to be considered correct.
Link to an actual Gradual Insanity applet.
![]() |
(Note: Depending on your platform and browser, the applet may or may not work well. Please let me know whether it does or doesn't on your particular platform, not that I can do much about it.)
In Gradual Insanity, the user selects a pattern of dots from a menu of different patterns. The patterns are identified by the line of colored squares across the top of the applet. The pattern is scrambled using only row and column rotations as moves. The user attempts to restore the puzzle to the goal state using the same kinds of moves.
A row of the puzzle is rotated to the left or right by clicking with the mouse alongside the row to the left or right, respectively, in an area approximately where the next dot would lie. A column of the puzzle is similarly rotated up or down by clicking above or below the column with the mouse.
When, through a series of such moves, the goal is reached, the program tells the user the goal is achieved. When this happens, the corresponding element of the menu bar (the colored squares) turns black to so indicate. (However, this blackening takes place only provided that no hints were requested in the process.)
The user may, at any time, request a different pattern by clicking the menu. She then scrambles the puzzle by clicking the Scramble button. The UnDo button undoes the last move. Moves can be undone all the way back to the initial scrambled state, if desired.
The following are required for a fully compliant solution:
The following are not required, but may be added for extra credit if desired:
See me about the Hint mechanism. Do not attempt to provide a brute-force solving mechanism, as there are too many states for this to be computationally feasible.
A minimum of three classes should be used:
A skeleton applet to be provided will give you sample code for:
You are advised to implement the following constructors and methods for class Pattern early on:
I will provide you with a skeleton applet in
To compile and run an applet, please follow these steps on turing or orion:
javac GradualInsanity.java
appletviewer GradualInsanity.html
In order to use the appletviewer, you will need to be on a computer which supports the X window system. For example, the workstations in Beckman 102 will, but a random Windows machine or Mac might not, unless you have the software (such as Mac/X). As an alternative to the appletviewer, you can try loading your html file in a web browser. Not all browsers are able to handle Java, and some that do don't do it that well.