org.jscience.computing.game
Interface AutoPlay

All Known Implementing Classes:
GameDriver

public interface AutoPlay

AutoPlay adds AI capabilites to a GamePlay by mapping Player objects to the game roles of a GamePlay. This enables to play against/with automated and intelligent opponents. This also provides the basis for any type of automated game simulation.
A word on the association of Player objects to GamePlay objects:
A GamePlay object (read: a game) has a certain number of 'game roles', each role can be assigned to a player. It is, however, possible that one Player object plays more than just one role in a given game (to account for any type of game setup). This is why - when dealing with game roles - an array of game roles is passed on instead of just one game role.

See Also:
Player, GamePlay

Method Summary
 GameMove autoMove()
          autoMove() carries out the next best move for the game and returns it; null is returned if no move was carried out.
 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
 double evaluateMove(GameMove move)
          The evaluation of the move is usually carried out by the Player object who plays the given move; consequently, the result should be interpreted from the perspective of the game roles this particular Player plays in the game.
 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 that is used by the following functions: hint() evaluateMove() autoMove()
 int[] getRoles(Player player)
          Players could play multiple roles in a game, so getRoles returns an array of Integers.
 GameMove hint(int playerRole)
          hint(int) delegates the evaluation of the best move to make to the Player object associated to the playerRole.
 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 setResponseTime(long milliseconds)
          sets the desired response time for the following functions: hint() evaluateMove() autoMove() A value of 0 indicates that the response time is only driven by getLevel().
 

Method Detail

getGame

GamePlay getGame()
returns the underlying GamePlay object


setLevel

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.


getLevel

int getLevel()
returns the game level

See Also:
setLevel(int)

autoMove

GameMove autoMove()
autoMove() carries out the next best move for the game and returns it; null is returned if no move was carried out. The result of this method is determined by the player to make the next move, the level and the response time that is in place.


getPlayer

Player getPlayer(int gameRole)
getPlayer(gameRole) returns the corresponding Player to the given gameRole - an integer between 0 and (getNumberOfPlayers()-1). If that role is not associated with a player, the function returns null.


getPlayers

Player[] getPlayers()
returns all Player objects that play the game; there may be duplicate Player objects present


changePlayer

Player changePlayer(int gameRole,
                    Player player)
                    throws CannotPlayGameException
changePlayer() enables to change the Player for a gameRole while the game is in progress; the old Player object is returned

Throws:
CannotPlayGameException

getRoles

int[] getRoles(Player player)
Players could play multiple roles in a game, so getRoles returns an array of Integers. if a player doesn't play a role in the game, the function returns null.


setResponseTime

void setResponseTime(long milliseconds)
sets the desired response time for the following functions:
  • hint()
  • evaluateMove()
  • autoMove()
  • A value of 0 indicates that the response time is only driven by getLevel().


    getResponseTime

    long getResponseTime()
    returns the response time that is used by the following functions:
  • hint()
  • evaluateMove()
  • autoMove()

  • hint

    GameMove hint(int playerRole)
    hint(int) delegates the evaluation of the best move to make to the Player object associated to the playerRole. The result of this method is determined by the player to make the next move, the level and the response time that is in place.


    evaluateMove

    double evaluateMove(GameMove move)
    The evaluation of the move is usually carried out by the Player object who plays the given move; consequently, the result should be interpreted from the perspective of the game roles this particular Player plays in the game.


    getRandomLegalMove

    GameMove getRandomLegalMove()
    returns a random legal move or null if no legal moves are available