|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.jscience.computing.game.AbstractGame
org.jscience.computing.game.puzzle.TilePuzzle
public class TilePuzzle
implements a very flexible tile puzzle game with various options
TilePuzzleSamples,
TilePuzzlePlayer,
Serialized Form| Constructor Summary | |
|---|---|
TilePuzzle()
uses TilePuzzleSamples.getNumberPuzzle(3) to initialize the puzzle |
|
TilePuzzle(java.lang.String name,
java.lang.Object[][] puzzle)
When constructed, the puzzle's current state equals its solution. |
|
TilePuzzle(java.lang.String name,
java.lang.Object[][] scrampledPuzzle,
java.lang.Object[][] destinationPuzzle)
If you want to set the initial state different from the solution puzzle by hand, this is the constructor to do it; be careful that the conventions (see TilePuzzle (String name, Object[][] puzzle)) for the puzzle are maintained for both given object arrays; also, both arrays must have the same dimensions and should contain the same objects. |
|
| Method Summary | |
|---|---|
java.lang.Object |
clone()
DOCUMENT ME! |
boolean |
equals(java.lang.Object obj)
DOCUMENT ME! |
java.lang.Object[][] |
getPuzzleMatrix()
DOCUMENT ME! |
double |
getResult(int playerRole)
DOCUMENT ME! |
java.lang.Object[][] |
getSolutionMatrix()
DOCUMENT ME! |
int[] |
getWinner()
DOCUMENT ME! |
int |
hashCode()
rather experimental at this point; needs to be tested for efficiency |
boolean |
isEndWhenSolved()
If isEndWhenSolved(), no legal moves are possible anymore once the puzzle is solved or when it has been determined that the game has no solution path. |
boolean |
isReverseMoveDisabled()
If isReverseMoveDisabled(), reverting the game status back to the state it came from (examining the last move) is not a legal move. |
boolean |
isSolved()
checks whether the puzzle state equals the solution and whether it is impossible to reach the goal - which is done by checking whether there are exactly 2 tiles exchanged. |
protected GameMove[] |
listLegalMoves()
DOCUMENT ME! |
int |
nextPlayer()
DOCUMENT ME! |
protected boolean |
popMove()
DOCUMENT ME! |
protected boolean |
pushMove(GameMove move)
DOCUMENT ME! |
void |
randomize(int numberOfMoves)
DOCUMENT ME! |
void |
randomize(int numberOfMoves,
long randomSeed)
DOCUMENT ME! |
void |
reset()
DOCUMENT ME! |
void |
setEndWhenSolved(boolean enable)
|
void |
setReverseMoveDisabled(boolean enable)
|
void |
shuffle()
DOCUMENT ME! |
void |
shuffle(long randomSeed)
note that calling shuffle() may make the puzzle unsolvable |
java.lang.String |
toString()
DOCUMENT ME! |
| Methods inherited from class org.jscience.computing.game.AbstractGame |
|---|
clearRedoList, gameOver, getGameName, getLastMove, getLastPlayer, getLegalMoves, getLegalMoves, getMoveHistory, getNumberOfRedoMoves, getRedoList, isLegalMove, isWinner, loadFromFile, makeMove, numberOfMoves, numberOfPlayers, redoMove, resetLegalMoves, resetLists, saveToFile, spawnChild, undoLastMove, undoMoves |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public TilePuzzle()
TilePuzzleSamples
public TilePuzzle(java.lang.String name,
java.lang.Object[][] puzzle)
TilePuzzleSamples
public TilePuzzle(java.lang.String name,
java.lang.Object[][] scrampledPuzzle,
java.lang.Object[][] destinationPuzzle)
TilePuzzleSamples| Method Detail |
|---|
public void reset()
public boolean isSolved()
throws PuzzleNotSolvableException
PuzzleNotSolvableException - if the puzzle state cannot reach the
solutionpublic void shuffle()
public void shuffle(long randomSeed)
randomSeed - DOCUMENT ME!public void randomize(int numberOfMoves)
numberOfMoves - DOCUMENT ME!
public void randomize(int numberOfMoves,
long randomSeed)
numberOfMoves - DOCUMENT ME!randomSeed - DOCUMENT ME!public java.lang.Object[][] getSolutionMatrix()
public java.lang.Object[][] getPuzzleMatrix()
public int[] getWinner()
public double getResult(int playerRole)
getResult in interface GamePlaygetResult in class AbstractGameplayerRole - DOCUMENT ME!
public int nextPlayer()
protected GameMove[] listLegalMoves()
listLegalMoves in class AbstractGamepublic void setEndWhenSolved(boolean enable)
isEndWhenSolved()public boolean isEndWhenSolved()
public void setReverseMoveDisabled(boolean enable)
isReverseMoveDisabled()public boolean isReverseMoveDisabled()
protected boolean pushMove(GameMove move)
pushMove in class AbstractGamemove - DOCUMENT ME!
protected boolean popMove()
popMove in class AbstractGamepublic java.lang.String toString()
toString in class AbstractGame
public java.lang.Object clone()
throws java.lang.CloneNotSupportedException
clone in interface GamePlayclone in class AbstractGamejava.lang.CloneNotSupportedException - DOCUMENT ME!AbstractGame.spawnChild(GameMove)public boolean equals(java.lang.Object obj)
equals in class java.lang.Objectobj - DOCUMENT ME!
public int hashCode()
hashCode in class java.lang.Object
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||