Project
I want to survive
AI-driven simulation developed in Unity, designed to explore autonomous agent behavior, decision-making, and pathfinding in a dynamically expanding environment.
The simulation focuses on a population of NPCs whose primary objective is survival through food acquisition, under constraints imposed by energy consumption, perception, and movement capabilities.
Each NPC is governed by a set of physical and behavioral parameters, including movement speed, vision range, reaction time, energy capacity, and energy gain from food. These parameters directly influence how agents perceive the environment and prioritize actions. For example, NPCs with greater vision range can detect food earlier but may move more slowly, while faster agents must rely on closer or opportunistic discoveries. Energy is continuously consumed as NPCs move, forcing agents to balance exploration efficiency with survival needs.
NPC behavior is implemented using a Finite State Machine (FSM), structured around states such as idle, random exploration, path planning, movement toward food, eating, resting, and dying. Transitions between states are driven by perceptual checks (e.g., food within vision range), path availability, energy thresholds, and internal memory. This design allows NPCs to react dynamically to environmental changes while maintaining predictable and debuggable behavior patterns.
The environment is generated procedurally using a fragmented map system. The world is composed of multiple interconnected fragment maps, each represented by a grid-based graph. As NPCs move and enter new areas, adjacent fragments are generated on demand, allowing the simulation to scale dynamically. Each fragment graph is merged into a global main graph, while a hierarchical abstract graph is constructed to support efficient navigation across large, expanding spaces.
Pathfinding is handled through a Hierarchical Pathfinding A* (HPA*) approach. NPCs compute paths by first reasoning on the abstract graph to identify high-level routes between fragments, then resolving detailed paths within local fragment graphs. This layered strategy ensures efficient path computation even as the environment grows, enabling real-time decision-making for multiple agents simultaneously.
Food spawning, environment variation, and graph connectivity are controlled through probabilistic parameters, introducing controlled randomness and ensuring that no two simulation runs evolve identically. Debugging tools such as gizmo-based graph visualization, path rendering, and camera switching between NPCs are integrated to support analysis and tuning of AI behavior.
Use arrows to browse media