ple.games.base¶
- class ple.games.base.Game(width, height, actions={})[source]¶
Game base class
ple.games.base.Game(width, height, actions={})
This Game class sets methods all games require. It should be subclassed when creating new games.
Parameters: width: int
The width of the game screen.
height: int
The height of the game screen.
actions: dict
Contains possible actions that the game responds too. The dict keys are used by the game, while the values are pygame.constants referring the keys.
Possible actions dict:
>>> from pygame.constants import K_w, K_s >>> actions = { >>> "up": K_w, >>> "down": K_s >>> }
- adjustRewards(rewards)[source]¶
Adjusts the rewards the game gives the agent
Parameters: rewards : dict
A dictonary of reward events to float rewards. Only updates if key matches those specificed in the init function.
- game_over()[source]¶
Gets the status of the game, returns True if game has hit a terminal state. False otherwise.
This is game dependent.
Returns: bool
- getGameState()[source]¶
Gets a non-visual state representation of the game.
Returns: dict or None
dict if the game supports it and None otherwise.
- getScore()[source]¶
Return the current score of the game.
Returns: int
The current reward the agent has received since the last init() or reset() call.
- getScreenDims()[source]¶
Gets the screen dimensions of the game in tuple form.
Returns: tuple of int
Returns tuple as follows (width, height).
- init()[source]¶
This is used to initialize the game, such reseting the score, lives, and player position.
This is game dependent.