org.jscience.computing.game.reversi
Class ReversiPlayer

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

public class ReversiPlayer
extends TemplatePlayer

adds AI to the ReversiGame

See Also:
ReversiGame, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class org.jscience.computing.game.TemplatePlayer
TemplatePlayer.MoveEvaluater, TemplatePlayer.Synchronizer
 
Field Summary
 int borderWeight
          DOCUMENT ME!
 int cornerWeight
          DOCUMENT ME!
 
Fields inherited from class org.jscience.computing.game.TemplatePlayer
levelOverwrite, monitors, orderMoves, playerName, SEARCH_ALPHABETA, SEARCH_MINMAX, searchOption
 
Constructor Summary
ReversiPlayer()
          Creates a new ReversiPlayer object.
ReversiPlayer(java.lang.String name)
          Creates a new ReversiPlayer object.
ReversiPlayer(java.lang.String name, int searchOption, boolean enableLogging)
          Creates a new ReversiPlayer object.
ReversiPlayer(java.lang.String name, int searchOption, boolean enableLogging, long randomSeed)
          Creates a new ReversiPlayer object.
 
Method Summary
 boolean canPlayGame(GamePlay game)
          DOCUMENT ME!
 double heuristic(GamePlay game, GameMove move, int[] role)
          this heuristic is basically counting pieces, but as long as the game is not over, it weights the pieces differently according to their potential for a final win.
 void setRandomSeed(long seed)
          if seed = 0, randomization is disabled
 java.lang.String toString()
          DOCUMENT ME!
 
Methods inherited from class org.jscience.computing.game.TemplatePlayer
disableTracking, enableTracking, evaluate, evaluate, getLevelOverwrite, getMonitors, getOrderMoves, getPlayerName, getSearchOption, numberOfPositionsSearched, numberOfRequests, performanceRatio, pruneMove, selectMove, setLevelOverwrite, setOrderMoves, setPlayerName, setSearchOption, setTracking, statsAsString, totalTimeTaken, trackingEnabled
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

borderWeight

public int borderWeight
DOCUMENT ME!


cornerWeight

public int cornerWeight
DOCUMENT ME!

Constructor Detail

ReversiPlayer

public ReversiPlayer()
Creates a new ReversiPlayer object.


ReversiPlayer

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

Parameters:
name - DOCUMENT ME!

ReversiPlayer

public ReversiPlayer(java.lang.String name,
                     int searchOption,
                     boolean enableLogging)
Creates a new ReversiPlayer object.

Parameters:
name - DOCUMENT ME!
searchOption - DOCUMENT ME!
enableLogging - DOCUMENT ME!

ReversiPlayer

public ReversiPlayer(java.lang.String name,
                     int searchOption,
                     boolean enableLogging,
                     long randomSeed)
Creates a new ReversiPlayer object.

Parameters:
name - DOCUMENT ME!
searchOption - DOCUMENT ME!
enableLogging - DOCUMENT ME!
randomSeed - 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!

heuristic

public double heuristic(GamePlay game,
                        GameMove move,
                        int[] role)
this heuristic is basically counting pieces, but as long as the game is not over, it weights the pieces differently according to their potential for a final win. Following this strategy, corner tiles (as they're not alterable anymore) are rated the highest, and border pieces are also rated higher than others.

Parameters:
game - DOCUMENT ME!
move - DOCUMENT ME!
role - DOCUMENT ME!
Returns:
DOCUMENT ME!
See Also:
TemplatePlayer

toString

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

Overrides:
toString in class TemplatePlayer
Returns:
DOCUMENT ME!