This project aims to simulate the exploration of Mars using a rover. The goal is to determine whether an area on Mars can be inhabited by a future human colony. The rover will scout the map, collect information about the terrain and resources, and log its findings into a file. The project follows the principles of SOLID, YAGNI, and the MVP approach.
The simulation keeps track of important information:
- Current step number
- Number of simulation steps required to reach a timeout
- Map of the area
- Location of the spaceship
- Rover information
- Exploration outcome
- Path to the log file
The rover's state includes:
- ID
- Current position
- Sight range
- Current routine
- Coordinate collections for movement and interesting objects
Data classes are created to hold this information.
The rover follows a loop of simulation steps until an outcome is reached. Each step consists of the following phases:
- Movement: The rover moves according to its state.
- Scan: The environment is scanned around the rover's new position, and the context is updated.
- Analysis: The updated context data is analyzed to determine the outcome.
- Log: The events of this round are appended to the log file.
- Step increment: The simulation step counter is incremented.
The phases are implemented using the Phase interface, and the ExplorationSimulator class performs these phases for each step. The class is open for extension to accommodate new phase types.
The rover follows different movement routines based on its objective. It has at least two routines:
- Exploring routine: The rover explores the field to gather information.
- Returning routine: The rover drives back to the spaceship to report findings.
The routines are implemented using the Routine interface. Additional routines can be added as needed.
During the Analysis phase, analyzers are used to determine if a simulation outcome has been reached. The following analyzers are implemented:
- Timeout analyzer: Checks if the current step number has reached the timeout.
- Success analyzer: Checks if the conditions for colonization have been met.
- Lack of resources analyzer: Checks if there are too few resources in the explored territories.
The analyzers are implemented using the Analyzer interface.
During the Log phase, the simulation state is written to a log file in the following format:
Aliens are introduced into the simulation. The rover is programmed to run back to the spaceship upon spotting an alien. The simulation outcome is set as "NOT_COLONIZABLE_ALIENS."
A new strategy is implemented to interact with aliens:
- Spotting an alien switches the rover into a new routine that drives it directly toward the alien.
- Upon direct contact, communication takes place. The responsible analyzer randomly selects an outcome: "NOT