Nano v1.0.0
Simulating Natural Selection
|
A class representing a single cycle in the simulation. More...
#include <simulation.h>
Public Member Functions | |
Cycle () | |
Necessary default constructor. More... | |
Cycle (std::vector< Entity > *t_entities, std::vector< Entity >::iterator *t_entitiesEndIter, size_t t_worldSize, std::vector< Food > *t_foods, size_t t_cycleId, size_t *t_lastEntityId) | |
void | CycleEnd () |
Prepares the entities for the next cycle. More... | |
void | update (float elapsedTime) |
Updates the current cycle. More... | |
Static Public Member Functions | |
static void | reproduceEntities (std::vector< Entity > &entities, std::vector< Entity >::iterator &entitiesEndIt, size_t *lastEntityId, size_t cycleId, std::vector< Food > *foods) |
Reproduces all entities that should reproduce with random traits inherited from their parent. More... | |
static void | equalEntitiesDistribution (std::span< Entity > entities, size_t wallSize) |
Distributes entities with equal spacing on the board. More... | |
static void | randomEntitiesDistribution (std::span< Entity > entities, size_t wallSize) |
Distributes entities randomly on the edges of the board. More... | |
static void | distributeEntities (std::span< Entity > entities, size_t wallSize) |
Determines if there is enough space for equal distribution and calls the appropriate function. More... | |
static void | handleFoodCount (std::vector< Food > &foods, int changeBy) |
static void | randomizeFoodPositions (std::span< Food > foods, size_t worldSize) |
Redistributes the food particles on the board. More... | |
Private Attributes | |
std::vector< Entity > * | m_entities |
std::vector< Entity >::iterator * | m_entitiesEndIter |
std::span< Entity > | activeEntities |
size_t * | m_lastEntityId |
std::vector< Food > * | m_foods |
size_t | m_worldSize |
size_t | m_cycleId |
bool | m_isCycleDone = false |
Friends | |
class | Simulation |
A class representing a single cycle in the simulation.
This class holds all the information and logic for the function of a cycle.
ss::bll::simulation::Cycle::Cycle | ( | ) |
Necessary default constructor.
ss::bll::simulation::Cycle::Cycle | ( | std::vector< Entity > * | t_entities, |
std::vector< Entity >::iterator * | t_entitiesEndIter, | ||
size_t | t_worldSize, | ||
std::vector< Food > * | t_foods, | ||
size_t | t_cycleId, | ||
size_t * | t_lastEntityId = nullptr |
||
) |
void ss::bll::simulation::Cycle::CycleEnd | ( | ) |
Prepares the entities for the next cycle.
Handles reproducing distributing and etc.
|
static |
Determines if there is enough space for equal distribution and calls the appropriate function.
|
static |
Distributes entities with equal spacing on the board.
|
static |
|
static |
Distributes entities randomly on the edges of the board.
|
static |
Redistributes the food particles on the board.
|
static |
Reproduces all entities that should reproduce with random traits inherited from their parent.
void ss::bll::simulation::Cycle::update | ( | float | elapsedTime | ) |
Updates the current cycle.
Loops through all the entities and calls their update. Checks if the cycle should end.
|
friend |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |