Holger's
Java API

com.antelmann.game.reversi
Class ReversiPlayer

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

public class ReversiPlayer
extends TemplatePlayer

adds AI to the ReversiGame

Author:
Holger Antelmann
See Also:
ReversiGame, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class com.antelmann.game.TemplatePlayer
TemplatePlayer.MoveEvaluater, TemplatePlayer.Synchronizer
 
Field Summary
 int borderWeight
           
 int cornerWeight
           
 
Fields inherited from class com.antelmann.game.TemplatePlayer
levelOverride, monitors, orderMoves, playerName, SEARCH_ALPHABETA, SEARCH_MINMAX, searchOption
 
Constructor Summary
ReversiPlayer()
           
ReversiPlayer(String name)
           
ReversiPlayer(String name, int searchOption, boolean enableLogging)
           
ReversiPlayer(String name, int searchOption, boolean enableLogging, long randomSeed)
           
 
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)
          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
 String toString()
          overridden to return some information about the player
 
Methods inherited from class com.antelmann.game.TemplatePlayer
disableTracking, enableTracking, evaluate, evaluate, getlevelOverride, getMonitors, getOrderMoves, getPlayerName, getSearchOption, numberOfPositionsSearched, numberOfRequests, performanceRatio, pruneMove, selectMove, setlevelOverride, 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

cornerWeight

public int cornerWeight
Constructor Detail

ReversiPlayer

public ReversiPlayer()

ReversiPlayer

public ReversiPlayer(String name)

ReversiPlayer

public ReversiPlayer(String name,
                     int searchOption,
                     boolean enableLogging)

ReversiPlayer

public ReversiPlayer(String name,
                     int searchOption,
                     boolean enableLogging,
                     long randomSeed)
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


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.

See Also:
TemplatePlayer

toString

public String toString()
Description copied from class: TemplatePlayer
overridden to return some information about the player

Overrides:
toString in class TemplatePlayer


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