Project: Step 2
Random Walks


Disclaimer: the automatically generated English translation is provided only for convenience and it may contain wording flaws. The original French document must be taken as reference!


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 & 19

Required Files : partie2.zip


Setup

Setup

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.

The project statement is designed so that your project can compile with the CMakeLists.txt file provided in the src/partie2 folder. To ensure compatibility with the provided test files, you will need to name your files the same as the classes they contain. For example, the Animal class will be coded in the Animal.[hpp][cpp] files.

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).

General Description of the Classes to Produce

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 :

  1. animals (which don't yet resemble anything very concrete);
  2. an environment (the "ecosystem" where the animals will evolve), which will be a "toric" surface visualized as a simple plane.

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 :

Model

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.

Modules to Program

The sections (modules) to be implemented in order to complete this step are as follows :

These different sections are not all of the same difficulty or length. Review each of them before you start programming this step. Note that section 3 constitutes the main difficulty of this step.

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]

Return to the main document