rtgym.arena package
Subpackages
- rtgym.arena.arena_shapes package
- Submodules
- rtgym.arena.arena_shapes.circle module
- rtgym.arena.arena_shapes.cornered_rectangle module
- rtgym.arena.arena_shapes.maze_0 module
- rtgym.arena.arena_shapes.maze_1 module
- rtgym.arena.arena_shapes.maze_2 module
- rtgym.arena.arena_shapes.rectangle module
- rtgym.arena.arena_shapes.trainer_0 module
- rtgym.arena.arena_shapes.triangle module
- rtgym.arena.arena_shapes.two_rooms module
- Module contents
Submodules
rtgym.arena.arena module
- class Arena(gym, **kwargs)[source]
Bases:
objectArena environment for spatial navigation.
The Arena defines the physical space where agents navigate, including walls, obstacles, and free space. It manages the spatial layout and provides utilities for position validation and random position generation.
- Parameters:
gym (RatatouGym) – Parent gym environment.
**kwargs – Additional keyword arguments.
- property arena_map
Get the arena map.
- Returns:
Arena map where 0 represents free space and 1 represents walls.
- Return type:
np.ndarray
- generate_random_pos(size)[source]
Get random positions in the arena
- get_specs()[source]
Get specs
- init_arena_map(shape, **kwargs)[source]
Set the arena map with a predefined shape.
- Parameters:
shape (str) – Shape of the arena map.
- property inv_arena_map
Get inverted arena map for visualization.
- Returns:
Inverted arena map where 1 is free space, 0 is wall.
- Return type:
np.ndarray
- load(path)[source]
Load arena map from an npz file
- Parameters:
path (str) – Path to the file where the arena map is saved.
- property map
Get arena map (alias for arena_map).
- Returns:
Arena map where 0 is free space, 1 is wall.
- Return type:
np.ndarray
- notify_subscribers()[source]
Notify all subscribers of arena changes.
Calls all registered subscriber functions to inform them that the arena has been modified.
- print_specs()[source]
Print specs
- Parameters:
path (str) – Path to the file where the arena map is saved.
- save(path)[source]
Save arena map as an npz file
- Parameters:
path (str) – Path to the file where the arena map is saved.
- set_arena_map(arena_map)[source]
Set arena map with custom layout.
Automatically pads edges with walls if they contain free space.
- Parameters:
arena_map (np.ndarray) – Arena map where 0 is free space, 1 is wall.
- Raises:
AssertionError – If arena_map is not a numpy array.
- subscribe(subscriber)[source]
Subscribe to arena change notifications.
- Parameters:
subscriber (callable) – Function to call when arena changes.
- validate_index(pos)[source]
Check if the position is in the arena
- vis()[source]
Visualize arena