|
Holger's Java API |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.antelmann.game.TemplatePlayer
com.antelmann.game.RandomPlayer
public class RandomPlayer
RandomPlayer provides a reference implementation of the Player interface. The RandomPlayer is a Player implementation that can play any game without further domain knowledge by providing either a purely random heuristic or heuristics that take advantage of the knowledge whether a GameMove can win or loose a given GamePlay. If the tree search options for its super class are set to a meaningful option and the getCheckForWin() is set to true, the RandomPlayer can actually play reasonably intelligent based on a given level when selecting moves (that is the RandomPlayer then ensures that if a win/loss situation can be seen within the given level, the prefered move by this RandomPlaye is the one that either wins or at least doesn't loose the game within the number of moves specified by the level).
GamePlay,
GameMove,
TemplatePlayer,
Player,
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 | |
|---|---|
RandomPlayer()
calls RandomPlayer(System.currentTimeMillis()) |
|
RandomPlayer(long randomSeed)
calls RandomPlayer("unnamed RandomPlayer") |
|
RandomPlayer(String name)
creates a RandomPlayer with no tree search option, no win checking and takes System.currentTimeMillis() as random seed. |
|
RandomPlayer(String name,
long randomSeed)
calls RandomPlayer(name, randomSeed, false, 0, false) |
|
RandomPlayer(String name,
long randomSeed,
boolean checkForWin,
int searchOption,
boolean enableTracking)
If checkForWin is set to true, heuristic() does preserve the knowledge about whether it wins or loses a game with the given move, in which case appropriate values (other than random ones) are returned. |
|
| Method Summary | |
|---|---|
boolean |
canPlayGame(GamePlay game)
always returns true, since the RandomPlayer can play any game |
boolean |
getCheckForWin()
|
double |
heuristic(GamePlay game,
GameMove move,
int[] role)
Preserves the knowlege of whether the move wins or looses the game only if getCheckForWin() returns true; return values are then randomized unless the random seed is set to 0. |
void |
setCheckForWin(boolean enable)
if enabled, the RandomPlayer's heuristic checks whether a given move can win the game and returns values accordingly |
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 |
| Constructor Detail |
|---|
public RandomPlayer()
public RandomPlayer(long randomSeed)
public RandomPlayer(String name)
public RandomPlayer(String name,
long randomSeed)
public RandomPlayer(String name,
long randomSeed,
boolean checkForWin,
int searchOption,
boolean enableTracking)
TemplatePlayer| Method Detail |
|---|
public boolean canPlayGame(GamePlay game)
public void setRandomSeed(long seed)
public void setCheckForWin(boolean enable)
public boolean getCheckForWin()
public double heuristic(GamePlay game,
GameMove move,
int[] role)
TemplatePlayerpublic String toString()
TemplatePlayer
toString in class TemplatePlayer
|
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||