Utopia 2
Framework for studying models of complex & adaptive systems.
Loading...
Searching...
No Matches
state.hh
Go to the documentation of this file.
1#ifndef UTOPIA_MODELS_CONTDISEASE_STATE_HH
2#define UTOPIA_MODELS_CONTDISEASE_STATE_HH
3
5
7
9enum class Kind : char {
11 empty = 0,
13 tree = 1,
15 infected = 2,
17 source = 3,
19 stone = 4
20};
21
23struct State {
26
28 unsigned age;
29
31 unsigned int cluster_id;
32
34 template<class RNG>
35 State (const DataIO::Config& cfg, const std::shared_ptr<RNG>& rng)
36 :
37 kind(Kind::empty),
38 age(0),
39 cluster_id(0)
40 {
41 // Check if p_tree is available to set up cell state
42 if (cfg["p_tree"]) {
43 const auto init_density = get_as<double>("p_tree", cfg);
44
45 // With this probability, the cell state is a tree
46 if (std::uniform_real_distribution<double>(0., 1.)(*rng)
47 < init_density)
48 {
50 }
51 }
52 }
53};
54
55
56} // namespace Utopia::Models::ContDisease
57
58
59#endif // UTOPIA_MODELS_CONTDISEASE_STATE_HH
YAML::Node Config
Type of a variadic dictionary-like data structure used throughout Utopia.
Definition types.hh:71
Container select_entities(const Manager &mngr, const DataIO::Config &sel_cfg)
Select entities according to parameters specified in a configuration.
Definition select.hh:213
Definition ContDisease.hh:18
Kind
The kind of the cell: empty, tree, infected, source, stone.
Definition state.hh:9
@ stone
Cell cannot be infected.
@ source
Cell is an infection source: constantly infected, spreading infection.
@ tree
Cell represents a tree.
The full cell struct for the ContDisease model.
Definition state.hh:23
unsigned age
The age of the cell.
Definition state.hh:28
Kind kind
The cell state.
Definition state.hh:25
unsigned int cluster_id
An ID denoting to which cluster this cell belongs.
Definition state.hh:31
State(const DataIO::Config &cfg, const std::shared_ptr< RNG > &rng)
Construct the cell state from a configuration and an RNG.
Definition state.hh:35