Game State#

The GameState is a dataclass that contains all information for internal tracking.

SoulsGym environments periodically reset attributes such as player HP, boss HP etc. To return the correct observations, we need to track any changes that have taken place. The GameState is the base class for this purpose. Each environment further extends the GameState with additional data members if necessary.

class soulsgym.envs.game_state.GameState(phase: int = 1, player_hp: int = 0, player_max_hp: int = 1, player_sp: int = 0, player_max_sp: int = 1, boss_hp: int | ~numpy.ndarray[~typing.Any, ~numpy.dtype[~numpy.int64]] = 0, boss_max_hp: int | ~numpy.ndarray[~typing.Any, ~numpy.dtype[~numpy.int64]] = 1, player_pose: ~numpy.ndarray[~typing.Any, ~numpy.dtype[~numpy.float32]] = <factory>, boss_pose: ~numpy.ndarray[~typing.Any, ~numpy.dtype[~numpy.float32]] = <factory>, camera_pose: ~numpy.ndarray[~typing.Any, ~numpy.dtype[~numpy.float32]] = <factory>, player_animation: str = 'NoAnimation', player_animation_duration: float = 0.0, boss_animation: str | list[str] = 'NoAnimation', boss_animation_duration: float | ~numpy.ndarray[~typing.Any, ~numpy.dtype[~numpy.float32]] = 0.0, lock_on: bool = False)#

Bases: object

Collect all game state information in a single data class.

copy() GameState#

Create a copy of the GameState.

Returns:

A copy of itself.

as_dict(deepcopy: bool = True) dict#

Create a dictionary from the data members.

Parameters:

deepcopy – Creates a deep copy of the data. Arrays will be copied instead of referenced.

Returns:

The class members and their values as a dictionary.

as_json() dict#

JSON encode the GameState class.

Returns:

The current GameState as dictionary for JSON serialization.

static from_dict(data_dict: dict) GameState#

Create a GameState object from a dictionary.

Parameters:

data_dict – Dictionary containing the GameState information.

Returns:

A GameState object with matching values.

__init__(phase: int = 1, player_hp: int = 0, player_max_hp: int = 1, player_sp: int = 0, player_max_sp: int = 1, boss_hp: int | ~numpy.ndarray[~typing.Any, ~numpy.dtype[~numpy.int64]] = 0, boss_max_hp: int | ~numpy.ndarray[~typing.Any, ~numpy.dtype[~numpy.int64]] = 1, player_pose: ~numpy.ndarray[~typing.Any, ~numpy.dtype[~numpy.float32]] = <factory>, boss_pose: ~numpy.ndarray[~typing.Any, ~numpy.dtype[~numpy.float32]] = <factory>, camera_pose: ~numpy.ndarray[~typing.Any, ~numpy.dtype[~numpy.float32]] = <factory>, player_animation: str = 'NoAnimation', player_animation_duration: float = 0.0, boss_animation: str | list[str] = 'NoAnimation', boss_animation_duration: float | ~numpy.ndarray[~typing.Any, ~numpy.dtype[~numpy.float32]] = 0.0, lock_on: bool = False) None#