|
Holger's Java API |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.antelmann.game.AbstractGame
com.antelmann.game.puzzle.Solitaire
public class Solitaire
A one-player game where the goal is to remove all 'peggs' on the board by jumping over them one by one.
| Constructor Summary | |
|---|---|
Solitaire()
uses SolitaireSamples.getSolitiare() to initialize the game |
|
Solitaire(String name,
int[][] board)
Instead of building the board array yourself, you can take advantage of the static methods of the class SolitaireSamples, which provides convenient standard configurations; if you build a configuration yourself, the convention for int[][] board is as follows. |
|
| Method Summary | |
|---|---|
Object |
clone()
Any inheriting class with non-primitive members must override this clone() method to provide a full deep copy of the object, which is essential for spawnChild() to work correctly. |
boolean |
equals(Object obj)
|
double |
getResult(int playerRole)
a default implementation for convenience which may suit most games that do not involve betting or any form of measuring how 'big' the win was. |
int |
getValueAt(int column,
int row)
|
int |
getValueAt(com.antelmann.game.puzzle.SolitairePosition pos)
|
int[] |
getWinner()
getWinner() returns an array of all winning game roles - as there could be more than one winner. |
int |
hashCode()
still experimental at this point |
boolean |
isSolved()
|
protected GameMove[] |
listLegalMoves()
listLegalMoves() returns the legal moves for this game. |
int |
nextPlayer()
nextPlayer() returns the integer representing the game role of the next player. |
int |
pegsLeft()
|
protected boolean |
popMove()
popMove undoes the last move by altering the game board to the stage before the last move happened. |
protected boolean |
pushMove(GameMove move)
pushMove takes a GameMove and alters the game according to to the move. |
String |
toString()
overridden to provide useful information about the game |
| Methods inherited from class com.antelmann.game.AbstractGame |
|---|
addObserver, clearRedoList, gameOver, getGameName, getLastMove, getLastPlayer, getLegalMoves, getLegalMoves, getMoveHistory, getNumberOfRedoMoves, getObservers, getRedoList, isLegalMove, isWinner, loadFromFile, makeMove, numberOfMoves, numberOfPlayers, redoMove, removeObserver, resetLegalMoves, resetLists, saveToFile, spawnChild, undoLastMove, undoMoves |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public Solitaire()
SolitaireSamples.getSolitaire()
public Solitaire(String name,
int[][] board)
SolitaireSamples| Method Detail |
|---|
public int[] getWinner()
GamePlay
public double getResult(int playerRole)
AbstractGame
getResult in interface GamePlaygetResult in class AbstractGamepublic int nextPlayer()
GamePlay
protected GameMove[] listLegalMoves()
AbstractGame
listLegalMoves in class AbstractGameprotected boolean pushMove(GameMove move)
AbstractGame
pushMove in class AbstractGameprotected boolean popMove()
AbstractGame
popMove in class AbstractGamepublic boolean isSolved()
public int pegsLeft()
public int getValueAt(com.antelmann.game.puzzle.SolitairePosition pos)
public int getValueAt(int column,
int row)
throws ArrayIndexOutOfBoundsException
ArrayIndexOutOfBoundsException
public Object clone()
throws CloneNotSupportedException
AbstractGamespawnChild() to work correctly. Ay overriding
of this method should still begin with a call to
super.clone(), though.
Also, note that this clone() method does not clone the
embedded GameMove objects, i.e. those are expected not to change
(except for their heuristics, which shouldn't affect game
functionality) - or the subclass will have to take care of this.
clone in interface GamePlayclone in class AbstractGameCloneNotSupportedExceptionAbstractGame.spawnChild(GameMove)public String toString()
AbstractGame
toString in class AbstractGamepublic int hashCode()
hashCode in class Objectpublic boolean equals(Object obj)
equals in class Object
|
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||