core.game_window#
The GameWindow is a wrapper around pixel_forge, a minimalistic Windows screenshot library.
The capture mechanism itself is implemented in rust to enable fast and efficient screen capture.
GameWindow also allows us to focus the Dark Souls III application on gym start.
- class soulsgym.core.game_window.GameWindow(game_id: str, processing: Callable | None = None, img_height: int | None = None, img_width: int | None = None)#
Bases:
objectProvide an interface with the game window.
The game resolution is particularly critical for the performance of the screen capture since a larger game window directly corresponds to larger images and more required computational power for processing.
- __init__(game_id: str, processing: Callable | None = None, img_height: int | None = None, img_width: int | None = None)#
Initialize the monitor and screen frame grab.
We offer an optional
processingcallable which can be used to transform images from the screen capture.- Parameters:
game_id – The name of the game.
processing – Optional function for raw image processing.
img_height – The height of the captured image.
img_width – The width of the captured image.
- property img_resolution: tuple[int, int]#
The resolution of the captured image.
- property focused: bool#
Check if the game window is currently focused.
- Returns:
True if the game window is currently focused, False otherwise.
- property img: ndarray#
The latest processed game screenshot.
- Returns:
The processed image.
- property raw_img: ndarray#
The latest raw game screenshot.
- Returns:
The raw image.
- focus()#
Shift the application focus of Windows to the game application.
Also sets the cursor within the game window.
- close()#
Close the game window capture.