World Module
The world module handles terrain generation and tile management.
Generator
Terrain
- class simulation_framework.src.world.terrain.TerrainProperties(passable: 'bool', fishable: 'bool', mineable: 'bool', harvestable: 'bool', movement_cost: 'float' = 1.0)[source]
Bases:
object
- classmethod for_terrain(terrain_type: TerrainType) TerrainProperties [source]
Tile
- class simulation_framework.src.world.tile.ResourceDeposit(resource_type: 'str', quantity: 'int', respawn_time: 'int' = 75, last_harvested: 'int' = 0, max_quantity: 'int' = 0, partial_respawn_rate: 'int' = 3, partial_respawn_interval: 'int' = 15)[source]
Bases:
object
- class simulation_framework.src.world.tile.Tile(x: int, y: int, terrain_type: TerrainType)[source]
Bases:
object
- add_resource(resource: ResourceDeposit) None [source]
- can_gather(resource_type: str | None = None, current_tick: int = 0) bool [source]
Check if resources can be gathered from this tile.
- Parameters:
resource_type – Specific resource type to check, or None for any resource
current_tick – Current simulation tick for respawn checking
- get_resources() List[ResourceDeposit] [source]
Resource Manager
Resource Manager for efficient resource tracking and querying.
Provides O(1) resource lookups instead of O(n²) world scanning. Tracks resource availability and respawn timing.
- class simulation_framework.src.world.resource_manager.ResourceManager(world: World)[source]
Bases:
object
Centralized resource tracking system.
Maintains spatial index of all resources for efficient queries. Tracks resource availability and respawn timing.
- cleanup_respawned_resources(current_tick: int) int [source]
Check depleted resources and mark them available if respawned. Returns count of resources that respawned.
- get_all_resource_positions(resource_type: str) List[Tuple[int, int]] [source]
Get all positions containing a resource type
- get_available_resources(resource_type: str, current_tick: int, agent_position: Tuple[int, int] | None = None, max_distance: float | None = None) List[Tuple[int, int]] [source]
Get list of available (harvestable) resource positions.
- Parameters:
resource_type – Type of resource to find
current_tick – Current simulation tick
agent_position – Optional agent position for distance filtering
max_distance – Optional maximum distance from agent
- Returns:
List of (x, y) positions with harvestable resources
- get_nearest_resource(resource_type: str, agent_position: Tuple[int, int], current_tick: int) Tuple[int, int] | None [source]
Find the nearest available resource of given type
- get_resource_statistics(resource_type: str | None = None) Dict [source]
Get statistics about resources