This project simulates an aquatic ecosystem where various types of creatures, called Bestiole, interact with one another in a virtual environment. The simulation features different behaviors and strategies for these creatures, controlled by a strategy pattern. It provides a graphical interface using the CImg library.
-
Aquarium.cpp / Aquarium.h: Implements the
Aquariumclass, the main container for the ecosystem. It initializes the simulation environment and orchestrates the interactions betweenBestioleinstances. -
Bestiole.cpp / Bestiole.h: Defines the
Bestioleclass, representing individual creatures. Includes properties like position, speed, and various sensory and defensive capabilities. -
Gregaire.cpp / Gregaire.h: Implements the
Gregairebehavior, where aBestiolealigns its orientation with its neighbors. -
Peureuse.cpp / Peureuse.h: Defines a "fearful" behavior, where a
Bestiolemoves away from others if they are detected within its sensory range. -
Kamikaze.cpp / Kamikaze.h: Implements an aggressive behavior, where a
Bestioleseeks the closest target and moves towards it with the intent of collision. -
Prevoyant.cpp / Prevoyant.h: Defines a predictive behavior where the
Bestioleestimates the future position of other creatures to avoid imminent collisions. -
Milieu.cpp / Milieu.h: Implements the
Milieuclass, which acts as the environment containing allBestioleinstances and handles their interactions and updates. -
IComportementStrategy.h: Defines the interface for implementing different behavioral strategies for
Bestiole. -
CImg.h: Part of the CImg library, providing image processing and graphical rendering capabilities.
-
UImg.h: Wrapper for the
CImglibrary to simplify its integration into the simulation. -
main.cpp: Entry point for the application. Sets up the aquarium dimensions and initializes the population of
Bestioleinstances with different behavior strategies. Starts the simulation loop.
-
Makefile: Defines the build process for compiling and linking the project.
-
Object Files (.o): Compiled object files for each source file.
-
Strategy Pattern: Different behaviors for
Bestioleare implemented using the strategy pattern, allowing dynamic behavior changes during runtime. -
Behavioral Diversity:
Gregaire: Aligns orientation with the average orientation of neighbors.Peureuse: Moves away from perceived threats.Kamikaze: Aggressively targets the closest creature.Prevoyant: Predicts and avoids potential collisions.
-
Graphical Visualization: The simulation is visualized in a window using the CImg library, displaying
Bestiolemovements and interactions in real time. -
Dynamic Behavior Switching:
Bestioleinstances with thehasMultipleBehaviorflag can switch between behaviors at runtime.
- Ensure you have a compatible C++ compiler (e.g., g++) and the CImg library installed.
- Run
maketo build the project:make - The executable will be generated in the project directory.
- Execute the compiled program:
./main - Follow the prompts to input the percentage distribution of different
Bestiolebehaviors. - Observe the simulation in the graphical window.
- CImg Library: Required for graphical rendering and image processing.
- Standard C++ Libraries: Includes
<iostream>,<vector>,<memory>,<cmath>, and others.
- Add more behaviors to enhance simulation dynamics.
- Optimize collision detection for better performance with large populations.
- Integrate additional visualization features, such as real-time statistics or detailed creature profiles.
This project is distributed under a dual license: CeCILL-C and CeCILL, as per the CImg library license requirements. Refer to CImg.h for detailed licensing information.