Project: Step 6
Extensions
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 extensions (optional).
There are all sorts of possible extensions to the project. A few ideas are listed below as a source of inspiration. Let your imagination run wild. Any “nice” (intellectually or visually) non-trivial extension of your work is welcome!
No materials are provided for this step. If you undertake this, be sure to place the corresponding code in a new directory partie6 so as to keep the mandatory part of the project intact in partie5.
Introduction of obstacles
One could imagine introducing obstacles (simple circular shapes to start with). Obstacles can be used to create autonomous zones within the culture dishes where certain categories of bacteria could evolve independently, for example.
The task will be to:
- model the obstacles;
- incorporate them into the system representation;
- ensuring that the presence of obstacles affects the movement of bacteria: they must bounce off obstacles upon collision. Tentacle bacteria will not be able to extend their tentacles beyond an obstacle.
Interactions between bacteria
The project, as developed so far, does not handle interactions between bacteria. You can address this by introducing interactions:
- indirect: one type of bacterium alters the environment, for example by releasing poison, and this alteration affects the lives of others;
- direct : one type of bacterium attacks others (or certain others).
In both cases, this will involve introducing a new type of bacterium whose representation and characteristics—such as division, mutation, etc.—are left to your discretion. Some guidelines on the issues to address are provided below.
Indirect interactions
Taking the example of bacteria releasing poison, you will need to consider the following questions:
- How should the presence of poison in the environment be modeled?
- How can we ensure that the bacteria are affected by the toxin?
- Which bacteria will be affected (all of them? Only those of a different type than the ones releasing the toxin? ...) and how?
- Should we introduce mutations related to toxin resistance?
- etc.
For example, we can consider that the amount of poison released in a given location is similar to a nutrient source (with bacteria perceiving the gradient), which may then be affected in terms of their energy levels and/or adopt a flight behavior.
Direct interactions
We can introduce a new category of bacteria that cause damage to others (see these examples or these, in French).
The task will then be:
-
to define the concept of "neighborhood" (the radius within which a bacterium can actually attack another);
- identifying the bacteria vulnerable to attack (present in the neighborhood) and determining whether all are vulnerable or only some (depending on their type);
- concretely defining the terms of the “attack” and its impact.
The main problems that will then arise are as follows:
- Identifying the bacteria in the neighborhood may be costly (this potentially involves scanning the entire collection of bacteria each time!).
- If differentiated interactions are handled (the aggressive bacterium does not attack those of its own type but attacks others in certain ways, and perhaps not all in the same way), how can we proceed without resorting to type testing?
A careful implementation can provide adequate answers to these questions:
- For problem 1: Rather than checking whether each of the other bacteria is in the vicinity of a given (aggressive) bacterium, it is possible to sample the space using a certain number of “cells” (portions of the space covering the culture dishes). The idea is that each bacterium knows at all times which cell it is in and each cell knows the list of bacteria it contains. Each time a bacterium moves, it is removed from its cell and added to its new cell. This would allow us to very quickly find the bacteria neighboring another bacterium. To access a cell from a bacterium, the simplest approach is to choose a representation convention, for example, carefully selecting the units of the positions so that the integer part of the coordinates directly accesses the corresponding cell, with the different cells then stored in memory as a three-dimensional array.
- For problem 2: you can draw inspiration from the "double dispatch" effect achieved in step 5 using method overloading.
Simulation with save points
It is useful to be able to save the state of a simulation (number and type of bacteria as well as their characteristics, nutrients present, etc.) so that it can be restarted in the same state later.
The idea is to store the data characterizing the simulation in a json file so that the simulation can be restarted based on this file later. To do this, you will need to study the features offered by the JSON/JSONSerializer files.
We will also need to extend the Application class by adding support for new keys as well as features enabling the implementation of the simulation with save points.
Other avenues to explore...
Many possibilities still exist; here are a few:
- simulate other group behaviors for bacteria (group attacks or encircling enemy bacteria);
- introduce other environmental factors affecting the simulation (light, pH, etc.);
- introduce more sophisticated behaviors for nutrient sources (degrading, changing appearance based on temperature or time, etc.)
- let your imagination run wild ...
Back to the main document