Entities Module

The entities module defines agents, NPCs, and their components.

Base Entity

class simulation_framework.src.entities.base.Entity(position: Tuple[int, int], name: str = 'Entity', stats: Stats | None = None, inventory_capacity: int = 50)[source]

Bases: ABC

apply_status_effect(effect: StatusEffect) None[source]
can_see(other: Entity, range_override: float | None = None) bool[source]
can_see_position(x: int, y: int, range_override: float | None = None) bool[source]
distance_to(other: Entity) float[source]
distance_to_position(x: int, y: int) float[source]
has_status_effect(effect_name: str) bool[source]
move_to(x: int, y: int, world: World) bool[source]
abstract on_death(killer: Entity | None = None) None[source]
remove_status_effect(effect_name: str) None[source]
take_damage(amount: int, attacker: Entity | None = None) int[source]
abstract update(world: World) None[source]
update_status_effects() None[source]
class simulation_framework.src.entities.base.StatusEffect(name: str, duration: int, effect_type: str = 'neutral', power: float = 0)[source]

Bases: object

apply_effect(entity: Entity) None[source]
refresh(additional_duration: int) None[source]
update(entity: Entity) bool[source]

Agent

class simulation_framework.src.entities.agent.Agent(position: Tuple[int, int], name: str = 'Agent', personality: Personality | None = None, character_class: CharacterClass | None = None, stats: Stats | None = None)[source]

Bases: Entity

act(world: World) None[source]

Execute actions based on current goals

add_relationship(entity_id: int, relationship_change: float) None[source]

Modify relationship with another entity

decide(world: World) None[source]

Make decisions about what to do next

get_agent_summary() Dict[source]

Get a summary of the agent’s state for debugging/analysis

get_dominant_skills(threshold: int = 5) List[Tuple[str, int]][source]

Get skills above the threshold

get_relationship(entity_id: int) float[source]

Get relationship level with another entity (-1 to 1)

get_skill_level(skill_name: str) int[source]

Get current level in a skill

is_hostile_to(entity: Entity) bool[source]

Check if this agent is hostile to another entity

on_death(killer: Entity | None = None) None[source]

Handle agent death

perceive(world: World) None[source]

Update agent’s knowledge of the world

update(world: World) None[source]

Main update loop for agent AI

simulation_framework.src.entities.agent.create_agent_with_archetype(position: Tuple[int, int], archetype: str, name: str | None = None) Agent[source]

Create an agent based on a personality archetype

simulation_framework.src.entities.agent.create_random_agent(position: Tuple[int, int], name: str | None = None) Agent[source]

Create an agent with randomized personality and class

NPC

class simulation_framework.src.entities.npc.NPC(position: Tuple[int, int], name: str = 'NPC', npc_type: str = 'neutral', stats: Stats | None = None, loot_table: LootTable | None = None, spawn_point: Tuple[int, int] | None = None, tether_radius: int = 10)[source]

Bases: Entity

add_patrol_point(point: Tuple[int, int]) None[source]
get_threat_level() str[source]
is_hostile_to(entity: Entity) bool[source]
on_death(killer: Entity | None = None) None[source]
set_aggressive(aggressive: bool = True) None[source]
set_patrol_route(points: List[Tuple[int, int]]) None[source]
set_target(target: Entity) None[source]

Set a target for combat - called by simulation when agent comes within aggro range

update(world: World) None[source]
simulation_framework.src.entities.npc.create_basic_goblin(position: Tuple[int, int]) NPC[source]
simulation_framework.src.entities.npc.create_forest_wolf(position: Tuple[int, int]) NPC[source]
simulation_framework.src.entities.npc.create_peaceful_villager(position: Tuple[int, int]) NPC[source]

Stats

class simulation_framework.src.entities.stats.Stats(max_health: 'int' = 100, health: 'int' = 100, max_stamina: 'int' = 100, stamina: 'int' = 100, max_magic: 'int' = 50, magic: 'int' = 50, attack_power: 'int' = 10, defense: 'int' = 5, speed: 'int' = 5)[source]

Bases: object

attack_power: int = 10
defense: int = 5
classmethod from_dict(data: Dict) Stats[source]
get_health_percentage() float[source]
get_magic_percentage() float[source]
get_stamina_percentage() float[source]
heal(amount: int) int[source]
health: int = 100
is_alive() bool[source]
magic: int = 50
max_health: int = 100
max_magic: int = 50
max_stamina: int = 100
reset() None[source]
restore_magic(amount: int) int[source]
restore_stamina(amount: int) int[source]
speed: int = 5
stamina: int = 100
take_damage(amount: int) int[source]
to_dict() Dict[source]
use_magic(amount: int) bool[source]
use_stamina(amount: int) bool[source]

Inventory

class simulation_framework.src.entities.inventory.Inventory(capacity: int = 50)[source]

Bases: object

add_item(item: Item, quantity: int = 1) int[source]
clear() None[source]
equip_tool(tool: Item, tool_type: str) Item | None[source]
equip_weapon(weapon: Item) Item | None[source]
classmethod from_dict(data: Dict, item_loader) Inventory[source]
get_all_items() List[InventorySlot][source]
get_equipped_tool(tool_type: str) Item | None[source]
get_equipped_weapon() Item | None[source]
get_item_count(item_name: str) int[source]
get_total_items() int[source]
has_item(item_name: str, quantity: int = 1) bool[source]
remove_item(item_name: str, quantity: int = 1) bool[source]
to_dict() Dict[source]
class simulation_framework.src.entities.inventory.InventorySlot(item: 'Item', quantity: 'int')[source]

Bases: object

add(amount: int) int[source]
item: Item
quantity: int