Holger's
Java API

com.antelmann.game.wolfsheep
Class WSPlayer

java.lang.Object
  extended by com.antelmann.game.TemplatePlayer
      extended by com.antelmann.game.wolfsheep.WSPlayer
All Implemented Interfaces:
Player, Serializable

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.

Author:
Holger Antelmann
See Also:
WolfsheepGame, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class com.antelmann.game.TemplatePlayer
TemplatePlayer.MoveEvaluater, TemplatePlayer.Synchronizer
 
Field Summary
 
Fields inherited from class com.antelmann.game.TemplatePlayer
levelOverride, monitors, orderMoves, playerName, SEARCH_ALPHABETA, SEARCH_MINMAX, searchOption
 
Constructor Summary
WSPlayer()
           
WSPlayer(String name)
           
 
Method Summary
 boolean canPlayGame(GamePlay game)
          canPlayGame() returns true only if the Player provides an applicable heuristic for the type of game given.
 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)
          overridden 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)
           
protected  double wolfHeuristic(WolfsheepGame game, int[] role)
           
 
Methods inherited from class com.antelmann.game.TemplatePlayer
disableTracking, enableTracking, evaluate, evaluate, getlevelOverride, getMonitors, getOrderMoves, getPlayerName, getSearchOption, numberOfPositionsSearched, numberOfRequests, performanceRatio, pruneMove, setlevelOverride, 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()

WSPlayer

public WSPlayer(String name)
Method Detail

canPlayGame

public boolean canPlayGame(GamePlay game)
Description copied from interface: Player
canPlayGame() returns true only if the Player provides an applicable heuristic for the type of game given. This way, a player can control whether it can a game.
 //Example:
 if (game instanceof MyGameClass) return true; else return false;
 // or:
 if (game.getClass() == myFavoriteGame.getClass()) return true; else return false;
 


setRandomSeed

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


selectMove

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

Specified by:
selectMove in interface Player
Overrides:
selectMove in class TemplatePlayer
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

See Also:
TemplatePlayer

wolfHeuristic

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

sheepHeuristic

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


(c) 2001-2006 Holger Antelmann - all rights reserved (contact: info@antelmann.com)
see www.antelmann.com/developer for further details and available downloads