Module Import alias Import alias identifier ImportFrom alias ImportFrom alias alias alias ClassDef bases NameLoad body Expr Str FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam NameParam NameParam NameParam NameParam NameParam NameParam NameParam defaults Num Num Num Dict NameLoad NameLoad NameLoad NameLoad NameLoad Num body Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr ListLoad Assign AttributeStore NameLoad attr ListLoad Assign AttributeStore NameLoad attr Num Assign AttributeStore NameLoad attr Num If NameLoad body Expr Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad If Call NameLoad NameLoad AttributeLoad AttributeLoad NameLoad attr attr body Assign AttributeStore NameLoad attr NameLoad orelse Assign AttributeStore NameLoad attr Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad Expr Call AttributeLoad AttributeLoad NameLoad attr attr AttributeLoad NameLoad attr Expr Call AttributeLoad AttributeLoad NameLoad attr attr TupleLoad Num Num AttributeLoad NameLoad attr Expr Call AttributeLoad AttributeLoad NameLoad attr attr Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad If CompareNotEq AttributeLoad NameLoad attr NameLoad body Assign AttributeStore NameLoad attr Call AttributeLoad AttributeLoad NameLoad attr attr If CompareEq AttributeLoad NameLoad attr NameLoad body Raise Call NameLoad Str orelse Assign AttributeStore NameLoad attr AttributeLoad Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr attr If BoolOpAnd CompareNotEq AttributeLoad NameLoad attr NameLoad CompareNotEq AttributeLoad NameLoad attr AttributeLoad NameLoad attr body Raise Call NameLoad BinOpMod Str TupleLoad AttributeLoad NameLoad attr AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam defaults body Expr Str If AttributeLoad NameLoad attr body Return BinOpDiv Num AttributeLoad NameLoad attr orelse Return Call AttributeLoad AttributeLoad AttributeLoad NameLoad attr attr attr AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam defaults body Expr Str Expr Call AttributeLoad NameLoad attr Assign AttributeStore AttributeLoad NameLoad attr attr Call AttributeLoad AttributeLoad NameLoad attr attr Call AttributeLoad NameLoad attr Num Num Assign AttributeStore AttributeLoad NameLoad attr attr Call AttributeLoad AttributeLoad NameLoad attr attr decorator_list FunctionDef arguments args NameParam defaults body Expr Str Assign NameStore Call AttributeLoad AttributeLoad AttributeLoad NameLoad attr attr attr If AttributeLoad NameLoad attr body Expr Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr Return NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str Return AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam defaults body Expr Str Return Call AttributeLoad AttributeLoad NameLoad attr attr decorator_list FunctionDef arguments args NameParam defaults body Expr Str Return Call AttributeLoad AttributeLoad NameLoad attr attr decorator_list FunctionDef arguments args NameParam defaults body Expr Str Return AttributeLoad AttributeLoad NameLoad attr attr decorator_list FunctionDef arguments args NameParam defaults body Expr Str Assign AttributeStore NameLoad attr ListLoad Assign AttributeStore NameLoad attr ListLoad Assign AttributeStore NameLoad attr Num Expr Call AttributeLoad AttributeLoad NameLoad attr attr decorator_list FunctionDef arguments args NameParam defaults body Expr Str Return Call AttributeLoad Call AttributeLoad AttributeLoad NameLoad attr attr Call AttributeLoad AttributeLoad NameLoad attr attr attr AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam defaults body Expr Str Assign NameStore Call AttributeLoad NameLoad attr Assign NameStore BinOpAdd BinOpAdd BinOpMult Num SubscriptLoad NameLoad ExtSlice Slice Slice Index Num BinOpMult Num SubscriptLoad NameLoad ExtSlice Slice Slice Index Num BinOpMult Num SubscriptLoad NameLoad ExtSlice Slice Slice Index Num Assign NameStore Call AttributeLoad Call AttributeLoad NameLoad attr NameLoad attr AttributeLoad NameLoad attr Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign NameStore Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str Return Call AttributeLoad AttributeLoad NameLoad attr attr decorator_list FunctionDef arguments args NameParam defaults body Expr Str Return AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam defaults body Expr Str Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr If BoolOpAnd CompareNotEq NameLoad NameLoad CompareNotEq AttributeLoad NameLoad attr NameLoad body Return Call AttributeLoad NameLoad attr NameLoad orelse Raise Call NameLoad Str decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Return Call NameLoad GeneratorExp Call AttributeLoad NameLoad attr NameLoad comprehension NameStore Call NameLoad AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam defaults body Expr Str If CompareEq AttributeLoad NameLoad attr NameLoad body Expr Call AttributeLoad AttributeLoad NameLoad attr attr decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str If Call AttributeLoad NameLoad attr body Return Num If CompareNotIn NameLoad Call AttributeLoad NameLoad attr body Assign NameStore AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr NameLoad For NameStore Call NameLoad AttributeLoad NameLoad attr body Assign NameStore Call AttributeLoad NameLoad attr Expr Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad Expr Call AttributeLoad NameLoad attr AugAssignAdd AttributeStore NameLoad attr AttributeLoad NameLoad attr Return Call AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad Dict Str NameLoad Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad Dict Str AttributeLoad NameLoad attr Assign AttributeStore NameLoad attr NameLoad Expr Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad Expr Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str Assign NameStore BinOpSub Call AttributeLoad AttributeLoad NameLoad attr attr AttributeLoad NameLoad attr Assign AttributeStore NameLoad attr Call AttributeLoad AttributeLoad NameLoad attr attr Return NameLoad decorator_list decorator_list
N/A N/A pygame N/A numpy np PIL Image pygame.constants KEYDOWN KEYUP K_F15 PLE N/A object N/A N/A 
        ple.PLE(game, fps=30, frame_skip=1, num_steps=1, reward_values={}, force_fps=True, display_screen=False, add_noop_action=True, NOOP=K_F15, state_preprocessor=None, rng=24)

        Main wrapper that interacts with games. Provides a similar interface to Arcade Learning Environment.

        Parameters
        ----------
        game: ple.game.base
            The game the PLE environment manipulates and maintains.

        fps: int (default: 30)
            The desired frames per second we want to run our game at. Typical settings are 30 and 60 fps.

        frame_skip: int (default: 1)
            The number of times we skip getting observations while repeat an action.

        num_steps: int (default: 1)
            The number of times we repeat an action.

        reward_values: dict
            This contains the rewards we wish to set give our agent based on different actions in game. The current defaults are as follows:

            .. code-block:: python

                rewards = {
                    "positive": 1.0,
                    "negative": -1.0,
                    "tick": 0.0,
                    "loss": -5.0,
                    "win": 5.0
                }

            Tick is given to the agent at each game step. You can selectively adjust the rewards by passing a dictonary with the key you want to change. Eg. If we want to adjust the negative reward and the tick reward we would pass in the following:

            .. code-block:: python

                rewards = {
                    "negative": -2.0,
                    "tick": -0.01
                }

            Keep in mind that the tick is applied at each frame. If the game is running at 60fps the agent will get a reward of 60*tick.

        force_fps: bool (default: True)
            If False PLE delays between game.step() calls to ensure the fps is specified. If not PLE passes an elapsed time delta to ensure the game steps by an amount of time consistent with the specified fps. This is usally set to True as it allows the game to run as fast as possible which speeds up training.

        display_screen: bool (default: False)
            If we draw updates to the screen. Disabling this speeds up interation speed. This can be toggled to True during testing phases so you can observe the agents progress.

        add_noop_action: bool (default: True)
            This inserts the NOOP action specified as a valid move the agent can make.

        NOOP: pygame.constants (default: K_F15)
            The key we want our agent to send that represents a NOOP. This is currently set to F15.

        state_preprocessor: python function (default: None)
            Python function which takes a dict representing game state and returns a numpy array.

        rng: numpy.random.RandomState, int, array_like or None. (default: 24)
            Number generator which is used by PLE and the games.

         __init__ N/A N/A self game fps frame_skip num_steps reward_values force_fps display_screen add_noop_action NOOP state_preprocessor rng N/A 30 1 1 N/A True False True K_F15 None 24 N/A N/A N/A self game game N/A N/A self fps fps N/A N/A self frame_skip frame_skip N/A N/A self NOOP NOOP N/A N/A self num_steps num_steps N/A N/A self force_fps force_fps N/A N/A self display_screen display_screen N/A N/A self add_noop_action add_noop_action N/A N/A self last_action N/A N/A N/A self action N/A N/A N/A self previous_score 0 N/A N/A self frame_count 0 N/A reward_values N/A N/A N/A N/A N/A self game adjustRewards reward_values N/A N/A isinstance rng N/A N/A np random RandomState N/A N/A N/A self rng rng N/A N/A N/A self rng N/A N/A N/A np random RandomState rng N/A N/A N/A N/A self game setRNG N/A self rng N/A N/A N/A N/A pygame display set_mode N/A 1 1 N/A pygame NOFRAME N/A N/A N/A N/A self game init N/A N/A self state_preprocessor state_preprocessor N/A N/A self state_dim None N/A N/A N/A self state_preprocessor None N/A N/A N/A self state_dim N/A N/A N/A self game getGameState N/A N/A N/A self state_dim None N/A N/A N/A ValueError Asked to return non-visual state on game that does not support it! N/A N/A N/A self state_dim N/A N/A N/A self state_preprocessor N/A self state_dim shape N/A N/A N/A N/A game allowed_fps None N/A N/A self fps N/A game allowed_fps N/A N/A N/A ValueError N/A Game requires %dfps, was given %d. N/A N/A game allowed_fps N/A game allowed_fps N/A _tick N/A N/A self N/A N/A N/A 
                Calculates the elapsed time between frames or ticks.
		 N/A N/A self force_fps N/A N/A N/A 1000.0 N/A self fps N/A N/A N/A N/A N/A N/A self game clock tick_busy_loop N/A self fps N/A init N/A N/A self N/A N/A N/A 
                Initializes the pygame environement, setup the display, and game clock.

                This method should be explicitly called.
                 N/A N/A N/A pygame init N/A N/A N/A self game screen N/A N/A N/A pygame display set_mode N/A N/A self getScreenDims 0 32 N/A N/A N/A self game clock N/A N/A N/A pygame time Clock N/A getActionSet N/A N/A self N/A N/A N/A 
                Gets the actions the game supports. Optionally inserts the NOOP action if PLE has add_noop_action set to True.

                Returns
                --------
                
                list of pygame.constants
                    The agent can simply select the index of the action to perform.

                 N/A actions N/A N/A N/A N/A self game actions values N/A N/A self add_noop_action N/A N/A N/A N/A actions append N/A self NOOP N/A actions N/A getFrameNumber N/A N/A self N/A N/A N/A 
                Gets the current number of frames the agent has seen since PLE was initialized.

                Returns
                --------

                int

                 N/A N/A self frame_count N/A game_over N/A N/A self N/A N/A N/A 
                Returns True if the game has reached a terminal state and False otherwise.

                This state is game dependent.

                Returns
                -------

                bool

                 N/A N/A N/A N/A self game game_over N/A score N/A N/A self N/A N/A N/A 
                Gets the score the agent currently has in game.

                Returns
                -------

                int

                 N/A N/A N/A N/A self game getScore N/A lives N/A N/A self N/A N/A N/A 
                Gets the number of lives the agent has left. Not all games have the concept of lives.

                Returns
                -------

                int

                 N/A N/A N/A self game lives N/A reset_game N/A N/A self N/A N/A N/A  
                Performs a reset of the games to a clean initial state.
                 N/A N/A self last_action N/A N/A N/A self action N/A N/A N/A self previous_score 0.0 N/A N/A N/A N/A self game reset N/A getScreenRGB N/A N/A self N/A N/A N/A 
                Gets the current game screen in RGB format.
                
                Returns
                --------
                numpy uint8 array
                    Returns a numpy array with the shape (width, height, 3).


                 N/A N/A N/A N/A N/A N/A pygame surfarray array3d N/A N/A N/A pygame display get_surface astype N/A np uint8 N/A getScreenGrayscale N/A N/A self N/A N/A N/A 
                Gets the current game screen in Grayscale format. Converts from RGB using relative lumiance.

                Returns
                --------
                numpy uint8 array
                    Returns a numpy array with the shape (width, height).


                 N/A frame N/A N/A self getScreenRGB N/A frame N/A N/A N/A 0.21 N/A frame N/A N/A N/A N/A 0 N/A 0.72 N/A frame N/A N/A N/A N/A 1 N/A 0.07 N/A frame N/A N/A N/A N/A 2 N/A frame N/A N/A N/A N/A np round frame astype N/A np uint8 N/A frame N/A saveScreen N/A N/A self filename N/A N/A N/A 
                Saves the current screen to png file.

                Parameters
                ----------

                filename : string
                    The path with filename to where we want the image saved.

                 N/A frame N/A N/A Image fromarray N/A N/A self getScreenRGB N/A N/A N/A frame save filename N/A getScreenDims N/A N/A self N/A N/A N/A 
		Gets the games screen dimensions.
                
                Returns
                -------
                
                tuple of int
                    Returns a tuple of the following format (screen_width, screen_height).
		 N/A N/A N/A N/A self game getScreenDims N/A getGameStateDims N/A N/A self N/A N/A N/A 
		Gets the games non-visual state dimensions.
                
                Returns
                -------
                
                tuple of int or None
                    Returns a tuple of the state vectors shape or None if the game does not support it.
		 N/A N/A self state_dim N/A getGameState N/A N/A self N/A N/A N/A 
                Gets a non-visual state representation of the game.

                This can include items such as player position, velocity, ball location and velocity etc.
                
                Returns
                -------

                dict or None
                    It returns a dict of game information. This greatly depends on the game in question and must be referenced against each game.
                    If no state is available or supported None will be returned back.

                 N/A state N/A N/A N/A self game getGameState N/A N/A N/A state None N/A N/A self state_preprocessor None N/A N/A N/A N/A self state_preprocessor state N/A N/A N/A ValueError Was asked to return state vector for game that does not support it! N/A act N/A N/A self action N/A N/A N/A 
		Perform an action on the game. We lockstep frames with actions. If act is not called the game will not run.

                Parameters
                ----------

                action : int
                    The index of the action we wish to perform. The index usually corresponds to the index item returned by getActionSet().

                Returns
                -------

                int
                    Returns the reward that the agent has accumlated while performing the action.

		 N/A N/A sum N/A N/A N/A self _oneStepAct action N/A i N/A range N/A self frame_skip N/A _draw_frame N/A N/A self N/A N/A N/A 
                Decides if the screen will be drawn too
                 N/A N/A N/A self display_screen True N/A N/A N/A N/A N/A pygame display update N/A _oneStepAct N/A N/A self action N/A N/A N/A 
                Performs an action on the game. Checks if the game is over or if the provided action is valid based on the allowed action set.
                 N/A N/A N/A self game_over N/A N/A 0.0 N/A N/A action N/A N/A self getActionSet N/A N/A action N/A self NOOP N/A N/A N/A self _setAction action N/A i N/A range N/A self num_steps N/A N/A time_elapsed N/A N/A self _tick N/A N/A N/A N/A self game step time_elapsed N/A N/A N/A self _draw_frame N/A N/A self frame_count N/A self num_steps N/A N/A N/A self _getReward N/A _setAction N/A N/A self action N/A N/A N/A 
			Pushes the action to pygame event queue.
		 N/A kd N/A N/A N/A pygame event Event KEYDOWN N/A key action N/A ku N/A N/A N/A pygame event Event KEYUP N/A key N/A self last_action N/A N/A self last_action action N/A N/A N/A N/A pygame event post kd N/A N/A N/A N/A pygame event post ku N/A _getReward N/A N/A self N/A N/A N/A 
                Returns the reward the agent has gained as the difference between the last action and the current one.
                 N/A reward N/A N/A N/A N/A self game getScore N/A self previous_score N/A N/A self previous_score N/A N/A N/A self game getScore N/A reward N/A N/A