Goal: Implement abstract animals capable of moving randomly in their environment and heading towards targets.
Required Concepts: classes, constructors/destructors, operator overloading, inheritance
These concepts are explained in courses 16, 17, 18 & 19Required Files : partie2.zip
The archive provided for this step contains a new version of the CMakeLists.txt file to compile the materials for this part. It also contains :
You will work for this step in the partie2/ directory.
As with the previous step, the method prototypes and attribute declarations will be in a file with the .hpp extension, while their definitions will be in a file with the .cpp extension.
You will need to follow this convention throughout the project.
(If you do not follow this approach, you will need to adapt the provided test files yourself).Before simulating lizards or scorpions, we will start by modeling more abstract animals capable only of:
The concepts we need to model to achieve this goal are therefore obviously :
We will begin by modeling animals using a very abstract automaton (the ChasingAutomaton, capable only of heading towards a target).
The most important element will be the implementation of the movement algorithm that will make your animals take random walks in their environment.
At this step, you will begin using your first graphical applications. A class Application.[hpp][cpp] is provided; it will serve as the basis for all your graphical simulation tests.
Here, in summary, is the architecture you will need to achieve at the end of this step :
Let’s proceed now with the beginning of the coding. In your program, you should ensure to properly encapsulate your classes, particularly by not giving public access to your attributes. You will also systematically provide destructors.
The descriptions suggested below are minimal. This is a first draft that we will refine as the project progresses. Feel free to add additional methods and attributes that you think are necessary.
The sections (modules) to be implemented in order to complete this step are as follows :
At the end of this step, you will have a simulation environment where you can add animals. They will wander randomly, and if a target enters their field of vision, they will head towards it:
| ← the field of vision is visualized clearly here | |
|
[Video: random movement of an animal with field of vision and target] |