|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.jscience.computing.game.GameDriver
public class GameDriver
The GameDriver provides an implementation for an AutoPlay. In addition, it handles Player objects that represent game roles in the GamePlay object, to provide for automated moves.
| Constructor Summary | |
|---|---|
GameDriver(GamePlay game)
initializes with RandomPlayer objects and level 0 |
|
GameDriver(GamePlay game,
Player[] players,
int level)
|
|
| Method Summary | |
|---|---|
GameMove |
autoMove()
autoMove() makes the move based on heuristics given by the Player; the time taken by the Player to evaluate the move will effect the time kept for that Player. |
Player |
changePlayer(int gameRole,
Player player)
changePlayer() enables to change the Player for a gameRole while the game is in progress; the old Player object is returned |
java.lang.Object |
clone()
Player objects are not cloned, but their references are maintained in the cloned object. |
double |
evaluateMove(GameMove move)
This function interfaces with the Player and returns the value of evaluate() while passing on the response time; note that a call to this function does not effect the time kept for the Player in the game. |
long |
getElapsedTime(int playerRole)
|
GamePlay |
getGame()
returns the underlying GamePlay object |
int |
getLevel()
returns the game level |
Player |
getPlayer(int gameRole)
getPlayer(gameRole) returns the corresponding Player to the given gameRole - an integer between 0 and (getNumberOfPlayers()-1). |
Player[] |
getPlayers()
returns all Player objects that play the game; there may be duplicate Player objects present |
GameMove |
getRandomLegalMove()
returns a random legal move or null if no legal moves are available |
long |
getResponseTime()
returns the response time limit used by the following functions: hint() autoMove() evaluateMove() |
int[] |
getRoles(Player player)
Players could play multiple roles in a game, so getRoles returns an array of Integers. |
GameMove |
hint(int playerRole)
hint() interfaces with the Player object that corresponds to the game role of this game. |
static GameDriver |
loadFromFile(java.lang.String fileLocation)
just a convenience function |
GameMove |
makeRandomMove()
|
void |
saveToFile(java.lang.String fileLocation)
just a convenience function |
void |
setLevel(int level)
The level in the game represents the 'depth' of the search tree (number of subsequent moves) a Player potentially searches through the game tree to evaluate a move. |
void |
setRandomSeed(long seed)
sets the seed for the Random object used for generating a random legal move |
void |
setResponseTime(long milliseconds)
sets the response time limit for the following functions: hint() autoMove() evaluateMove() |
java.lang.String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public GameDriver(GamePlay game)
public GameDriver(GamePlay game,
Player[] players,
int level)
| Method Detail |
|---|
public void setRandomSeed(long seed)
getRandomLegalMove()
public Player changePlayer(int gameRole,
Player player)
throws CannotPlayGameException
AutoPlay
changePlayer in interface AutoPlayCannotPlayGameExceptionpublic long getElapsedTime(int playerRole)
public final void setLevel(int level)
AutoPlay
setLevel in interface AutoPlaypublic final int getLevel()
AutoPlay
getLevel in interface AutoPlayAutoPlay.setLevel(int)public GameMove autoMove()
autoMove in interface AutoPlaypublic GameMove makeRandomMove()
public Player getPlayer(int gameRole)
throws java.lang.IndexOutOfBoundsException
AutoPlay
getPlayer in interface AutoPlayjava.lang.IndexOutOfBoundsExceptionpublic int[] getRoles(Player player)
AutoPlay
getRoles in interface AutoPlaypublic void setResponseTime(long milliseconds)
setResponseTime in interface AutoPlaypublic long getResponseTime()
getResponseTime in interface AutoPlay
public GameMove hint(int playerRole)
throws java.lang.IndexOutOfBoundsException
hint in interface AutoPlayjava.lang.IndexOutOfBoundsException - if the given playerRole doesn't existPlayer.selectMove(GamePlay,int[],int,long)public Player[] getPlayers()
AutoPlay
getPlayers in interface AutoPlaypublic GameMove getRandomLegalMove()
AutoPlay
getRandomLegalMove in interface AutoPlaypublic double evaluateMove(GameMove move)
evaluateMove in interface AutoPlayPlayer.evaluate(GamePlay,GameMove,int[],int,long)public void saveToFile(java.lang.String fileLocation)
public static GameDriver loadFromFile(java.lang.String fileLocation)
public java.lang.String toString()
toString in class java.lang.Object
public java.lang.Object clone()
throws java.lang.CloneNotSupportedException
clone in class java.lang.Objectjava.lang.CloneNotSupportedExceptionpublic GamePlay getGame()
AutoPlay
getGame in interface AutoPlay
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||