dreamerx.rlgym.rewards module#

Custom reward functions for RLGym environments.

class dreamerx.rlgym.rewards.CloseReward(*args: list[Any], use_diff: bool = True, **kwargs: dict[str, Any])#

Bases: RewardFunction

A reward function that rewards agents for being close to the ball in RLGym.

__init__(*args: list[Any], use_diff: bool = True, **kwargs: dict[str, Any]) → None#

Initialize the CloseReward.

Parameters:
  • args (Any) – Positional arguments for the base class.

  • use_diff (bool) – Whether to use the difference in distance for reward calculation. If False, the reward is based on the absolute distance. (Default: False)

  • kwargs (dict[str, Any]) – Keyword arguments for the base class.

_compute_dist(state: GameState) → dict[str, float]#

Compute the distance from each agent to the ball.

Parameters:

state (rlgym.rocket_league.api.GameState) – The current game state.

Returns:

A dictionary mapping each agent to their distance from the ball.

Return type:

dict[str, float]

get_rewards(agents: list[str], state: GameState, is_terminated: dict[str, bool], is_truncated: dict[str, bool], shared_info: dict[str, Any]) → dict[str, float]#

Compute the rewards for the given state based on closeness to the ball.

Parameters:
  • agents (list[str]) – A list of agent identifiers.

  • state (rlgym.rocket_league.api.GameState) – The current game state.

  • is_terminated (dict[str, bool]) – A dictionary indicating if each agent’s episode has terminated.

  • is_truncated (dict[str, bool]) – A dictionary indicating if each agent’s episode has been truncated.

  • shared_info (dict[str, Any]) – Shared info.

Returns:

A dictionary mapping each agent to their computed reward.

Return type:

dict[str, float]

reset(agents: list[str], initial_state: GameState, shared_info: dict[str, Any]) → None#

Reset the reward function, currently does nothing.

Parameters:
  • agents (list[str]) – A list of agent identifiers.

  • initial_state (rlgym.rocket_league.api.GameState) – The initial game state.

  • shared_info (dict[str, Any]) – Shared info.