.d8888b. 888 888 8888888b. 8888888b. .d88888b. .d8888b.
d88P Y88b888 888 888 Y88b888 Y88bd88P" "Y88bd88P Y88b
Y88b. 888 888 888 888888 888888 888888 888
"Y888b. Y88b d88P 888 d88P888 d88P888 888888
"Y88b. Y88b d88P 8888888P" 8888888P" 888 888888 88888
"888 Y88o88P 888 888 T88b 888 888888 888
Y88b d88P Y888P 888 888 T88b Y88b. .d88PY88b d88P
"Y8888P" Y8P 888 888 T88b "Y88888P" "Y8888P88
Copyright (C) 2016 Julia Besson & Ilya Skurikhin
This program aims to simulate an environment in which bees, living in hives, collect pollen from flowers to keep the other bees in their hive alive. Bears interact with the environment through eating hive's nectar, endangering bees.
The only direct dependency of the code is SFML. In order to compile with SCons, you will need to have that too.
In order to use the documentation, you will need Doxygen.
Documentation can be generated with doxygen, from the /doc directory with the provided Doxyfile.
The default run command is scons application-run
, which will build and run the
code in default configuration, using the appbig.json config file in the /res
directory. You can change the configuration file used with the --cfg=<file>
argument.
We have extended the configuration file to include new features, as well as to tweak previous features.
There are two configuration files available for a big and a small world.
Here is an overview of the program : - The world is created, automatically generating the texture and the bees and bears. - Hives die if they are in an area that is not optimal for the bees - New hives are created if a hive is in a good location - Stats are shown for the number of Bees, Hives and Flowers
By default, the world specified in the configuration file will be loaded, and Hives, with Bees, as well as Flowers will be generated accoring to the configuration file.
Press h
to add a Hive at the cursor location.
Press c
to add a Cave at the cursor location.
Press f
to add a Flower at the cursor location.
Press r
to generate a new environment.
Press i
to load world to file.
Press s
to save world to file.
Press d
to enter debug mode.
Press w
to display humidity levels.
You can move around by dragging the world and scrolling to zoom in and out. You can resize the window by dragging the edges. If you right click an animal, you the camera will follow it around the world. The debug mode will allow you to see humidity rates, animals energy rates and pollen and nectar rates.
Here is documentation for the logic behind each class of the program.
Gives texture of each cell that the other elements will them be built on top of. The data from this class is heavy, and will therefore be saved on demand.
The representation of the world is toric, and therefore for most elements, there is no boundard to the world, this includes:
- seeds during generation
- humidity calculations
- bees flying and detecting flowers
- hiveable detection
- bear activity
During regeneration, seeds are created, they move randomly on the map and pass their texture to the cell that they land on. Once the seeds have been moved a number of times defined in the config file, the resulting world goes through smoothing, during which islands of a certain texture are eliminated.
Humidity levels are generated by calculating a matrix of humidity as a function of distance for one quadrant of the area that would need to be humidified (while the humidity is higher than the threshold specified). This matrix is then added to the surrounding cells of a water cell.
To test a set of configuration settings, you can set the number of hives and flowers to be generated automatically at each startup, or load from file. These settings are in the 'initial' section of the config file.
The environment contains all the elements of the simulation, including the world, the hives, and the flowers.
This class contains methods that move objects through the world while interacting with the environment.
It defines the ways in which objects move in the environment.
The Hive is the home of the Bees, where they can replenish their nectar and where new Bees are created. The Hive usually has one or more Queens, and will die when it runs out of nectar.
If the Hive has no more nectar, the Bees will be in survival mode and will try to go out for more nectar even if thet do not have the required energy level. The Queen will give up her own energy resources up til her minimum limit.
There are several kinds of Bee in the project.
The Queen Bee gives birth to all the other Bees. It also creates the hive and cares for the hive in times of need by sacrificing its energy.
Each Hive is created with a Queen. The Queen will start to save energy when a certain energy level is reached, and if the Queen reaches a critical level the Queen will give birth to a new Queen and leave to create a new Hive.
The new Hive must be in an appropriate area and at least a certain distance from the previous Hive of the Queen.
The Worker Bee collects nectar from flowers and drops it off at the Hive.
The Scout Bee finds Flower positions and gives those positions to Worker Bees when it is in the Hive.
A Cave is the living place of the Bear. It does not have an energy level, and only serves as the sleeping place of the Bear. There is a limit to the number of Caves that can be placed.
Bears can not reproduce. They live in a cave where they hibernate for a certain time. Then they move randomly and if they pass by a hive they eat its nectar. There is a limit to the number of Bears that can be in the environment that is given by the number of Caves that can be placed.
There are a certain number of interfaces available in order to guarantee that certain actions can be performed on a set of classes that inherit from these interfaces.
Guarantees the implementation of a void drawOn(sf::RenderTexture)
method.
Guarantees the implementation of a void update(sf::Time)
method.
Guarantees the implementation of a void reloadConfig()
method. These methods
are called when the user wants the configuration file to be reloaded, which
would be most useful when regenerating the world afterwards. Since this
interface is inherited by many classes, its inheritance is virtual in most
cases, such that intermediate methods can be defined to reload the attributes of
a higher class, but it is up to the lowest class to call all the higher methods
should the lowest one be called.