This project implements an autonomous robot simulation named TerraBot. The system manages a complex ecosystem where the robot interacts with various entities (Air, Water, Soil, Plants, and Animals) to monitor and improve environmental conditions.
- TerraBot (Singleton): The main actor of the simulation. It maintains its
batterylevel, currentcoordinates, anInventoryof scanned items, and aKnowledgeBasefor learned facts. - SimulationManager: Orchestrates the simulation flow. It handles the
runSimulationloop, processes commands via a factory, and ensures the environment updates chronologically. - EnvironmentUpdater: Manages the "physics" of the world. It calculates plant growth, oxygen production, humidity changes, and animal movement/eating habits based on whether the robot has scanned the relevant entities.
- Command Pattern: All actions (moving, scanning, recharging) are decoupled into command objects created by the
CommandFactory.
- Energy Management: The robot consumes energy for actions and can enter a
rechargestate, during which achargingTimeRemainingtimer must expire before it becomes active again. - Environmental Cycles: Every iteration, the
EnvironmentUpdaterrefreshes the map. For example, if aPlantandWaterare both scanned, the plant's maturity increases. - Knowledge Acquisition: Through
ScanObjectandLearnFact, the robot populates itsInventoryandKnowledgeBaseto unlock further interactions with the environment.