|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.jscience.computing.game.BookPlayer
public class BookPlayer
BookPlayer is a Player wrapper that can significantly improve normal Player performance by predefining move selections. This is achieved by internally using a Hashtable object as a book. When asked to select a move in a game, the BookPlayer first checks its book (Hashtable) to see whether a given game is present as a key; If so, it will return the GameMove object stored as the associated value to that key (which is assumed to be the desired move earlier put in the book (which is the Hashtable). Only if the GameBook doesn't contain the game in question, the selection is passed on to the embedded Player object for standard procedure, as all other requests defined in the Player interface are routed to the embedded player as well. Naturally, the BookPlayer relies on a properly maintained book to perform well.
| Constructor Summary | |
|---|---|
BookPlayer(Player player)
Creates a new BookPlayer object. |
|
BookPlayer(java.lang.String name,
Player player)
allows the BookPlayer to have a name different from the embedded player |
|
| Method Summary | |
|---|---|
int |
bookHits()
returns the number of times that this BookPlayer had a hit on the embedded GameBook while processing a move selection |
boolean |
canPlayGame(GamePlay game)
DOCUMENT ME! |
void |
changePlayer(Player player)
DOCUMENT ME! |
double |
evaluate(GamePlay game,
GameMove move,
int[] role,
int level,
long milliseconds)
DOCUMENT ME! |
java.util.Hashtable |
getBook()
allows access to the embedded book to add/remove GamePlay-GameMove pairs |
Player |
getPlayer()
DOCUMENT ME! |
java.lang.String |
getPlayerName()
DOCUMENT ME! |
double |
heuristic(GamePlay game,
GameMove move,
int[] role)
DOCUMENT ME! |
boolean |
pruneMove(GamePlay game,
GameMove move,
int[] role)
DOCUMENT ME! |
GameMove |
selectMove(GamePlay game,
int[] role,
int level,
long milliseconds)
first checks the embedded book for a pre-stored move |
void |
setBook(java.util.Hashtable<GamePlay,GameMove> book)
Sets the internal book used by this BookPlayer. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public BookPlayer(Player player)
player - DOCUMENT ME!
public BookPlayer(java.lang.String name,
Player player)
getPlayerName()| Method Detail |
|---|
public java.lang.String getPlayerName()
getPlayerName in interface Playerpublic boolean canPlayGame(GamePlay game)
canPlayGame in interface Playergame - DOCUMENT ME!
public boolean pruneMove(GamePlay game,
GameMove move,
int[] role)
pruneMove in interface Playergame - DOCUMENT ME!move - DOCUMENT ME!role - DOCUMENT ME!
public double evaluate(GamePlay game,
GameMove move,
int[] role,
int level,
long milliseconds)
evaluate in interface Playergame - DOCUMENT ME!move - DOCUMENT ME!role - DOCUMENT ME!level - DOCUMENT ME!milliseconds - DOCUMENT ME!
GameUtils,
TemplatePlayer,
GamePlay.getResult(int)
public double heuristic(GamePlay game,
GameMove move,
int[] role)
heuristic in interface Playergame - DOCUMENT ME!move - DOCUMENT ME!role - DOCUMENT ME!
TemplatePlayer
public GameMove selectMove(GamePlay game,
int[] role,
int level,
long milliseconds)
selectMove in interface Playergame - DOCUMENT ME!role - DOCUMENT ME!level - DOCUMENT ME!milliseconds - DOCUMENT ME!
TemplatePlayerpublic int bookHits()
public void setBook(java.util.Hashtable<GamePlay,GameMove> book)
book - DOCUMENT ME!public java.util.Hashtable getBook()
public void changePlayer(Player player)
player - DOCUMENT ME!public Player getPlayer()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||