core.game_input#

The game_input module provides an interface to trigger keystrokes from within the gym.

class soulsgym.core.game_input.GameInput(game_id: str, game_speed: float = 1.0)#

Bases: object

Trigger keystrokes by calling the Windows user32 API.

__init__(game_id: str, game_speed: float = 1.0)#

Initialize the key state dictionary.

Parameters:
  • game_id – The name of the game.

  • game_speed – The speed of the game. We need to adapt the duration of a key press to the game speed, because the game recognizes a key press only if it is held for a certain amount of in-game time.

add_action(action: str)#

Queue a single action for the next game input.

Action string has to be contained in static.keybindings.

Parameters:

action – The pressed action.

add_actions(actions: list[str])#

Queue multiple actions for the next game input.

Action strings have to be contained in static.keybindings.

Parameters:

actions – A list of pressed actions.

update_input()#

Update the pressed keys state with queued actions and execute key presses/releases.

Actions have to be queued with GameInput.add_action() and GameInput.add_actions(). Some actions (e.g. rolling) require an immediate release after pressing the key, or else the player would perform a different action such as running. All other keystrokes remain pressed as long as successive updates contain the corresponding action (e.g. running).

reset()#

Release all keys and set the press state to False.

single_action(action: str, press_time: float = 0.15)#

Perform a single action for a given amount of time.

Parameters:
  • action – The action to trigger (see static.keybindings).

  • press_time – The duration of the key press.