|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.ObjectPuzzleModel
public class PuzzleModel
Yuriy Kozlov
PuzzleModel.java -- Final Project
There is a virtual environment where the chain of cubes is. The chain is
represented by a linked list of the coordinates [x,y,z] of the cubes, where x
points down, y points to the right, and z points into the screen.
This class is used to solve the puzzle.
| Constructor Summary | |
|---|---|
PuzzleModel()
Creates a new PuzzleModel, with an empty to-try queue, empty process, blank puzzle state, empty tried hashset, 0 size, and a blank result. |
|
PuzzleModel(PuzzleState state)
Creates a new PuzzleModel with the given PuzzleState, a to-try queue containing it, an empty process, an empty tried hashset, the size of the given state, and a blank result. |
|
| Method Summary | |
|---|---|
java.util.LinkedList |
bruteSolve()
Recursive brute solve. |
boolean |
checkTooLong()
Checks if there are any straight rows of cubes that are longer than the size of the puzzle. |
int |
countBends()
Counts the number of cubes that are corners. |
int |
countStraights()
Counts the number of cubes that go straight through (are not corners). |
PuzzleState |
getCurrent()
Returns the current PuzzleState. |
java.lang.String |
getResult()
Returns the result, a string which says whether the puzzle was solved. |
static void |
main(java.lang.String[] args)
Called when the file is run. |
static void |
printState2d(PuzzleState state)
This prints out the state to the screen by printing the z coordinate of the visible cubes in the XY plane. |
static void |
printState2d2(PuzzleState state)
This prints out the state to the screen by printing the z coordinate of the visible cubes in the XZ plane. |
java.util.LinkedList |
puzzleNotSolved()
Called when the puzzle cannot be solved. |
java.util.LinkedList |
puzzleSolved(PuzzleState solved)
Called when the puzzle has been solved. |
java.util.LinkedList |
smartSolve()
Does some checks to see if the puzzle is unsolvable before calling bruteSolve. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public PuzzleModel()
public PuzzleModel(PuzzleState state)
state - A starting PuzzleState.| Method Detail |
|---|
public PuzzleState getCurrent()
public java.lang.String getResult()
public java.util.LinkedList bruteSolve()
public java.util.LinkedList smartSolve()
public boolean checkTooLong()
public int countStraights()
public int countBends()
public java.util.LinkedList puzzleSolved(PuzzleState solved)
solved - The solved state.
public java.util.LinkedList puzzleNotSolved()
public static void printState2d(PuzzleState state)
state - A state to print out.public static void printState2d2(PuzzleState state)
state - A state to print out.public static void main(java.lang.String[] args)
args - Not used.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||