Utopia 2
Framework for studying models of complex & adaptive systems.
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
Utopia::Models::PredatorPrey::State Struct Reference

Cell State struct. More...

#include <PredatorPrey.hh>

Collaboration diagram for Utopia::Models::PredatorPrey::State:
Collaboration graph
[legend]

Public Member Functions

template<class RNGType >
 State (const DataIO::Config &cfg, const std::shared_ptr< RNGType > &rng)
 Construct a cell state with the use of a RNG.
 

Public Attributes

SpeciesState predator
 The state a predator on this cell has.
 
SpeciesState prey
 The state a prey on this cell has.
 
bool moved_predator
 Flag to indicate if the predator on this cell has already moved

 

Detailed Description

Cell State struct.

Constructor & Destructor Documentation

◆ State()

template<class RNGType >
Utopia::Models::PredatorPrey::State::State ( const DataIO::Config cfg,
const std::shared_ptr< RNGType > &  rng 
)
inline

Construct a cell state with the use of a RNG.

35 :
36 predator{},
37 prey{},
38 moved_predator(false)
39 {
40 std::uniform_real_distribution<double> dist(0., 1.);
41
42 // Get the threshold probability value
43 const auto p_prey = get_as<double>("p_prey", cfg);
44 const auto p_predator = get_as<double>("p_predator", cfg);
45
46 // Set a prey on a cell with the given probability by generating a
47 // random number in [0, 1) and compare it to wanted probability.
48 if (dist(*rng) < p_prey){
49 prey.on_cell = true;
50 prey.resources = get_as<double>("init_resources",
51 cfg["prey"]);
52 }
53
54 // Set a predator on a cell with the given probability.
55 if (dist(*rng) < p_predator){
56 predator.on_cell = true;
57 predator.resources = get_as<double>("init_resources",
58 cfg["predator"]);
59 }
60 }
Container select_entities(const Manager &mngr, const DataIO::Config &sel_cfg)
Select entities according to parameters specified in a configuration.
Definition select.hh:213
double resources
The internal resources reservoir.
Definition species.hh:16
bool on_cell
Whether the species is on the cell.
Definition species.hh:13
bool moved_predator
Flag to indicate if the predator on this cell has already moved
Definition PredatorPrey.hh:30
SpeciesState prey
The state a prey on this cell has.
Definition PredatorPrey.hh:27
SpeciesState predator
The state a predator on this cell has.
Definition PredatorPrey.hh:24

Member Data Documentation

◆ moved_predator

bool Utopia::Models::PredatorPrey::State::moved_predator

Flag to indicate if the predator on this cell has already moved

◆ predator

SpeciesState Utopia::Models::PredatorPrey::State::predator

The state a predator on this cell has.

◆ prey

SpeciesState Utopia::Models::PredatorPrey::State::prey

The state a prey on this cell has.


The documentation for this struct was generated from the following file: