org.jscience.computing.game.puzzle
Class WSPuzzle

java.lang.Object
  extended by org.jscience.computing.game.AbstractGame
      extended by org.jscience.computing.game.puzzle.WSPuzzle
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, GamePlay

public class WSPuzzle
extends AbstractGame

WSPuzzle implements the 'Wolf & Sheep Puzzle'. This puzzle is inspired by
http://www.fitzweb.com/brainteasers/wolves.shtml
The solution can be easily found by searching through 6379 game positions.

See Also:
Serialized Form

Field Summary
static byte SHEEP
          DOCUMENT ME!
static byte WOLF
          DOCUMENT ME!
 
Constructor Summary
WSPuzzle()
          Creates a new WSPuzzle object.
 
Method Summary
 java.lang.Object clone()
          DOCUMENT ME!
 int[] getWinner()
          DOCUMENT ME!
protected  GameMove[] listLegalMoves()
          lists all legal moves.
static void main(java.lang.String[] args)
          solves the puzzle and then fires up a GUI to let you examine the solution
 int nextPlayer()
          DOCUMENT ME!
protected  boolean popMove()
          DOCUMENT ME!
protected  boolean pushMove(GameMove move)
          DOCUMENT ME!
static GamePlay searchSolution()
          tries to solve the puzzle with GameUtils functions
 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
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

WOLF

public static final byte WOLF
DOCUMENT ME!

See Also:
Constant Field Values

SHEEP

public static final byte SHEEP
DOCUMENT ME!

See Also:
Constant Field Values
Constructor Detail

WSPuzzle

public WSPuzzle()
Creates a new WSPuzzle object.

Method Detail

main

public static void main(java.lang.String[] args)
solves the puzzle and then fires up a GUI to let you examine the solution

Parameters:
args - DOCUMENT ME!

searchSolution

public static GamePlay searchSolution()
tries to solve the puzzle with GameUtils functions

Returns:
DOCUMENT ME!

listLegalMoves

protected GameMove[] listLegalMoves()
lists all legal moves. To minimize the possibilities, fist place a wolf, then a sheep, then a wolf, etc. until 5 wolfs and 3 sheeps are on the board (the 7th and the 8th move is placing a wolf).

Specified by:
listLegalMoves in class AbstractGame
Returns:
DOCUMENT ME!

pushMove

protected boolean pushMove(GameMove move)
DOCUMENT ME!

Specified by:
pushMove in class AbstractGame
Parameters:
move - DOCUMENT ME!
Returns:
DOCUMENT ME!

popMove

protected boolean popMove()
DOCUMENT ME!

Specified by:
popMove in class AbstractGame
Returns:
DOCUMENT ME!

nextPlayer

public int nextPlayer()
DOCUMENT ME!

Returns:
DOCUMENT ME!

getWinner

public int[] getWinner()
DOCUMENT ME!

Returns:
DOCUMENT ME!

toString

public java.lang.String toString()
DOCUMENT ME!

Overrides:
toString in class AbstractGame
Returns:
DOCUMENT ME!

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
DOCUMENT ME!

Specified by:
clone in interface GamePlay
Overrides:
clone in class AbstractGame
Returns:
DOCUMENT ME!
Throws:
java.lang.CloneNotSupportedException - DOCUMENT ME!
See Also:
AbstractGame.spawnChild(GameMove)