org.jscience.computing.game.wolfsheep
Class WSPlayer

java.lang.Object
  extended by org.jscience.computing.game.TemplatePlayer
      extended by org.jscience.computing.game.wolfsheep.WSPlayer
All Implemented Interfaces:
java.io.Serializable, Player

public class WSPlayer
extends TemplatePlayer

WSPlayer adds AI to the WolfsheepGame; can play both, wolf and sheep. Note: It seems that for the sheeps to win, the game level needs to be set to 7 or higher. If the sheeps move with sufficient intelligence, they cannot loose; the wolf can only win based on mistakes of the sheeps. Also, if the level is set high, the wolf tends to play too defensively (as it anticipates the right move from the sheep that won't let it get through, anyway), so if you want to play against the wolf, set the level lower to make it play more dangerous.

See Also:
WolfsheepGame, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class org.jscience.computing.game.TemplatePlayer
TemplatePlayer.MoveEvaluater, TemplatePlayer.Synchronizer
 
Field Summary
 
Fields inherited from class org.jscience.computing.game.TemplatePlayer
levelOverwrite, monitors, orderMoves, playerName, SEARCH_ALPHABETA, SEARCH_MINMAX, searchOption
 
Constructor Summary
WSPlayer()
          Creates a new WSPlayer object.
WSPlayer(java.lang.String name)
          Creates a new WSPlayer object.
 
Method Summary
 boolean canPlayGame(GamePlay game)
          DOCUMENT ME!
 double heuristic(GamePlay game, GameMove move, int[] role)
          only cares for the first given role in the role array
 GameMove selectMove(GamePlay game, int[] role, int level, long milliseconds)
          overwritten to provide a sensible opening that doesn't suffer from the horizon effect
 void setRandomSeed(long seed)
          if seed = 0, randomization is disabled
protected  double sheepHeuristic(WolfsheepGame game, int[] role)
          DOCUMENT ME!
protected  double wolfHeuristic(WolfsheepGame game, int[] role)
          DOCUMENT ME!
 
Methods inherited from class org.jscience.computing.game.TemplatePlayer
disableTracking, enableTracking, evaluate, evaluate, getLevelOverwrite, getMonitors, getOrderMoves, getPlayerName, getSearchOption, numberOfPositionsSearched, numberOfRequests, performanceRatio, pruneMove, setLevelOverwrite, setOrderMoves, setPlayerName, setSearchOption, setTracking, statsAsString, toString, totalTimeTaken, trackingEnabled
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

WSPlayer

public WSPlayer()
Creates a new WSPlayer object.


WSPlayer

public WSPlayer(java.lang.String name)
Creates a new WSPlayer object.

Parameters:
name - DOCUMENT ME!
Method Detail

canPlayGame

public boolean canPlayGame(GamePlay game)
DOCUMENT ME!

Parameters:
game - DOCUMENT ME!
Returns:
DOCUMENT ME!

setRandomSeed

public void setRandomSeed(long seed)
if seed = 0, randomization is disabled

Parameters:
seed - DOCUMENT ME!

selectMove

public GameMove selectMove(GamePlay game,
                           int[] role,
                           int level,
                           long milliseconds)
overwritten to provide a sensible opening that doesn't suffer from the horizon effect

Specified by:
selectMove in interface Player
Overrides:
selectMove in class TemplatePlayer
Parameters:
game - DOCUMENT ME!
role - DOCUMENT ME!
level - DOCUMENT ME!
milliseconds - DOCUMENT ME!
Returns:
DOCUMENT ME!
See Also:
TemplatePlayer.Synchronizer, TemplatePlayer.MoveEvaluater

heuristic

public double heuristic(GamePlay game,
                        GameMove move,
                        int[] role)
only cares for the first given role in the role array

Parameters:
game - DOCUMENT ME!
move - DOCUMENT ME!
role - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
java.lang.Error - DOCUMENT ME!
See Also:
TemplatePlayer

wolfHeuristic

protected double wolfHeuristic(WolfsheepGame game,
                               int[] role)
DOCUMENT ME!

Parameters:
game - DOCUMENT ME!
role - DOCUMENT ME!
Returns:
DOCUMENT ME!

sheepHeuristic

protected double sheepHeuristic(WolfsheepGame game,
                                int[] role)
DOCUMENT ME!

Parameters:
game - DOCUMENT ME!
role - DOCUMENT ME!
Returns:
DOCUMENT ME!