-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodel.h
46 lines (38 loc) · 1.38 KB
/
model.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#ifndef PP_MODEL_H
#define PP_MODEL_H
#include "fpmas/model/spatial/grid.h"
#include "fpmas/synchro/ghost/ghost_mode.h"
#include "yaml-cpp/yaml.h"
#include "grass.h"
#include "agent.h"
FPMAS_DEFINE_GROUPS(GROW, MOVE, EAT, DIE, REPRODUCE);
class PreyPredatorModelBase : public virtual fpmas::api::model::SpatialModel<Grass> {
private:
// Behaviors must be declared at the class level
Behavior<Grass> grow {&Grass::grow};
Behavior<PreyPredatorAgentBase> move {&PreyPredatorAgentBase::move};
Behavior<PreyPredatorAgentBase> eat {&PreyPredatorAgentBase::eat};
Behavior<PreyPredatorAgentBase> die {&PreyPredatorAgentBase::die};
Behavior<PreyPredatorAgentBase> reproduce {&PreyPredatorAgentBase::reproduce};
static void load_static_config(const YAML::Node& config);
protected:
void initModel(const YAML::Node& config);
};
template<template<typename> class SyncMode>
class PreyPredatorModel :
public PreyPredatorModelBase,
public fpmas::model::GridModel<SyncMode, Grass> {
public:
PreyPredatorModel(const YAML::Node& config) {
this->initModel(config);
}
PreyPredatorModel(
const YAML::Node& config,
fpmas::api::scheduler::Scheduler& scheduler,
fpmas::api::runtime::Runtime& runtime,
fpmas::api::graph::LoadBalancing<fpmas::api::model::AgentPtr>& lb
) : fpmas::model::GridModel<SyncMode, Grass>(scheduler, runtime, lb) {
this->initModel(config);
}
};
#endif