![]() |
Nano v1.0.0
Simulating Natural Selection
|
A class representing the simulation. More...
#include <simulation.h>
Public Member Functions | |
| const std::vector< Food > & | getFoods () const |
| Getter for all the food particles. More... | |
| const Entity * | getEntityById (size_t id) |
| Getter for entity by id. More... | |
| void | setEntityTraits (size_t id, const types::Trait &traits) |
| Sets the traits of an entity. More... | |
| Simulation (types::SimulationInfo t_simInfo) | |
| Constructor for the Simulation class. More... | |
| size_t | getTotalAliveEntities () const |
| Calculates the amount of the total alive entities. More... | |
| size_t | getTotalDiedEntities () const |
| Calculates the amount of the total died entities. More... | |
| types::Trait | getAvgTraits () const |
| Calculates the average traits of all entities for the whole simulation. More... | |
| void | saveSimulationInfo (std::optional< std::string > fileName) const |
| Generates and attempts to save all of the information gathered throughout the simulation. More... | |
| void | update (float elapsedTime) |
| Updates the simulation. More... | |
| void | setFoodChange (int foodChange) |
Static Public Member Functions | |
| static std::span< Entity > | getActiveEntities (std::vector< Entity > &entities, std::vector< Entity >::iterator &iter) |
| Returns only the alive entities in the current cycle. More... | |
| static void | repositionEntitiesIter (std::vector< Entity > &entities, std::vector< Entity >::iterator &iter) |
| Sets an appropriate position for the iterator used to mark the point between the alive and dead entities in the entities' container. More... | |
Public Attributes | |
| types::SimulationInfo | m_simInfo |
| std::vector< Entity > | m_entities |
| std::vector< Entity >::iterator | m_entitiesEndIt |
| std::vector< Food > | m_foods |
| size_t | m_lastEntityId = 1 |
| size_t | m_currentCycle_n = 1 |
| Cycle | m_currentCycle |
| bool | isSimulationDone = false |
Private Member Functions | |
| void | cleanEntities () |
| Cleans up unused entities after the simulation has finished. More... | |
Friends | |
| class | Cycle |
A class representing the simulation.
This class holds all the information and logic for the simulation to be able to manage all of it's subclasses (not in inheritance meaning).
| ss::bll::simulation::Simulation::Simulation | ( | types::SimulationInfo | t_simInfo | ) |
Constructor for the Simulation class.
Constructs the Simulation class with approriate ss::types::SimulationInfo.
| t_simInfo | object of user defined type ss::types::SimulationInfo holding the data. |
|
private |
Cleans up unused entities after the simulation has finished.
|
static |
Returns only the alive entities in the current cycle.
| ss::types::Trait ss::bll::simulation::Simulation::getAvgTraits | ( | ) | const |
Calculates the average traits of all entities for the whole simulation.
| const ss::bll::simulation::Entity * ss::bll::simulation::Simulation::getEntityById | ( | size_t | id | ) |
Getter for entity by id.
| id | The id of the wanted entity. |
| const std::vector< ss::bll::simulation::Food > & ss::bll::simulation::Simulation::getFoods | ( | ) | const |
Getter for all the food particles.
| size_t ss::bll::simulation::Simulation::getTotalAliveEntities | ( | ) | const |
Calculates the amount of the total alive entities.
| size_t ss::bll::simulation::Simulation::getTotalDiedEntities | ( | ) | const |
Calculates the amount of the total died entities.
|
static |
Sets an appropriate position for the iterator used to mark the point between the alive and dead entities in the entities' container.
| void ss::bll::simulation::Simulation::saveSimulationInfo | ( | std::optional< std::string > | fileName | ) | const |
Generates and attempts to save all of the information gathered throughout the simulation.
| void ss::bll::simulation::Simulation::setEntityTraits | ( | size_t | id, |
| const types::Trait & | traits | ||
| ) |
Sets the traits of an entity.
| id | The id of the entity whose traits you want to edit. |
| traits | The traits you want to be set on the entity. |
| void ss::bll::simulation::Simulation::setFoodChange | ( | int | foodChange | ) |
| void ss::bll::simulation::Simulation::update | ( | float | elapsedTime | ) |
Updates the simulation.
Checks if the simulation is over and updates the current cycle.
|
friend |
| bool ss::bll::simulation::Simulation::isSimulationDone = false |
| Cycle ss::bll::simulation::Simulation::m_currentCycle |
| size_t ss::bll::simulation::Simulation::m_currentCycle_n = 1 |
| std::vector<Entity> ss::bll::simulation::Simulation::m_entities |
| std::vector<Entity>::iterator ss::bll::simulation::Simulation::m_entitiesEndIt |
| std::vector<Food> ss::bll::simulation::Simulation::m_foods |
| size_t ss::bll::simulation::Simulation::m_lastEntityId = 1 |
| types::SimulationInfo ss::bll::simulation::Simulation::m_simInfo |