|
|||||||||
| 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.wolfsheep.WolfsheepGame
public class WolfsheepGame
an implementation of the wolf&sheep game which is played on a chess-like board; it uses the BoardPosition from the chess package for convenience. The game is played with 1 'wolf' and 4 'sheeps'; the setup and rules are somewhat simillar to checker, but way simpler. Wolf and sheeps start on opposite sites of the board. The sheeps can only move forward diagonal; the wolf can move back&forth, but only diagonal, also. Hence, each sheep has 2 move option at most and the wolf has 4 move options at most. The sheeps' goal is to contain the wolf, so that it cannot move anymore. The wolf's goal is to bypass the sheeps closing line and reach the other side of the board. If the wolf moves first, the wolf represents game role 0 and the sheeps represent 1. If the sheeps move first, these game roles are reversed.
BoardPosition,
Serialized Form| Field Summary | |
|---|---|
static byte |
SHEEP
DOCUMENT ME! |
static byte |
WOLF
DOCUMENT ME! |
| Constructor Summary | |
|---|---|
WolfsheepGame()
initiates the game with the wolf being the first player |
|
WolfsheepGame(byte firstPlayer)
can initiate the game with either the wolf or the sheeps as the first player; |
|
| Method Summary | |
|---|---|
java.lang.Object |
clone()
DOCUMENT ME! |
boolean |
equals(java.lang.Object obj)
DOCUMENT ME! |
BoardPosition |
getSheepPosition(int index)
accepts index 0 - 3 |
int[] |
getWinner()
DOCUMENT ME! |
BoardPosition |
getWolfPosition()
DOCUMENT ME! |
protected GameMove[] |
listLegalMoves()
DOCUMENT ME! |
int |
nextPlayer()
DOCUMENT ME! |
protected boolean |
popMove()
DOCUMENT ME! |
protected boolean |
pushMove(GameMove move)
DOCUMENT ME! |
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, getResult, isLegalMove, isWinner, loadFromFile, makeMove, numberOfMoves, numberOfPlayers, redoMove, resetLegalMoves, resetLists, saveToFile, spawnChild, undoLastMove, undoMoves |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final byte SHEEP
public static final byte WOLF
| Constructor Detail |
|---|
public WolfsheepGame()
public WolfsheepGame(byte firstPlayer)
WOLF,
SHEEP| Method Detail |
|---|
protected GameMove[] listLegalMoves()
listLegalMoves in class AbstractGameprotected boolean pushMove(GameMove move)
pushMove in class AbstractGamemove - DOCUMENT ME!
protected boolean popMove()
popMove in class AbstractGamepublic int nextPlayer()
public int[] getWinner()
public BoardPosition getWolfPosition()
public BoardPosition getSheepPosition(int index)
throws java.lang.ArrayIndexOutOfBoundsException
index - DOCUMENT ME!
java.lang.ArrayIndexOutOfBoundsException - DOCUMENT ME!public boolean equals(java.lang.Object obj)
equals in class java.lang.Objectobj - DOCUMENT ME!
public 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)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||