-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRoman.hxx
172 lines (116 loc) · 5.69 KB
/
Roman.hxx
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
#ifndef __Roman_hxx__
#define __Roman_hxx__
#include <Agent.hxx>
#include <Action.hxx>
#include <AgentController.hxx>
#include <string>
#include <tuple>
namespace Epnet
{
class AgentController;
class Roman : public Engine::Agent
{
int _resources; // MpiBasicAttribute
private:
std::vector<std::string> proposedConnections;
void requestConnectionFrom(std::string source);
std::vector<std::string> receivedConnections;
std::vector<std::string> validRcvConnections;
int ackConnectionFrom(std::string target);
int nackConnectionFrom(std::string target);
std::vector<std::string> validSendConnections;
void receiveMessageFrom(std::string source, std::string msg);
std::vector<std::tuple<std::string,std::string> > receivedMessages;
//type, quantity, maxQuantity, price, need, productionRate
std::vector<std::tuple<std::string,double,double,double,double,double> > listGoods;
int receiveGoodFrom(std::string source, std::string type, double value);
std::vector<std::string> listProducedGoods;
std::vector<std::tuple<std::string,std::string,double,double> > listReceivedTrades;
std::vector<std::tuple<std::string,std::string,double,double> > listProposedTrades;
int receiveTradeFrom(std::string source, std::string type, double value, double currency);
void removeReceivedTrade(std::string source, std::string type, double value, double currency);
void removeProposedTrade(std::string source, std::string type, double value, double currency);
void consumeEssentialResources();
void checkDeath();
int _maxActions;
int _nbTrades;
double _score;
AgentController* _controller;
double _mutationRate;
public:
Roman( const std::string & id, std::string controllerType );
Roman( const std::string & id, std::string controllerType,double mutationRate,std::string selectionProcess,std::string innovationProcess);
virtual ~Roman();
void updateState();
void selectActions();
void updateKnowledge();
void registerAttributes();
void serialize();
void setResources( int resources );
int getResources() const;
void resetNbTrades();
void increaseNbTrades(int value);
int getMaxActions();
double getScore() {return _score;};
void setScore(double value) {_score = value ;};
// setup connections
void proposeConnectionTo(std::string target);
void killConnectionTo(std::string target);
std::vector<std::string> getProposedConnections() {return proposedConnections;};
std::vector<std::string> getValidSendConnections() {return validSendConnections;};
void acceptConnectionFrom(std::string source);
void refuseConnectionFrom(std::string source);
void killConnectionFrom(std::string source);
std::vector<std::string> getReceivedConnections() {return receivedConnections;};
std::vector<std::string> getValidRcvConnections() {return validRcvConnections;};
void proposeConnectionBetween(std::string source, std::string target);
void killConnectionBetween(std::string source, std::string target);
void killConnections(std::string target);
//message system
void sendMessageTo(std::string target, std::string msg);
std::vector<std::tuple<std::string,std::string> > getReceivedMessages() {return receivedMessages;};
//good system
void addGoodType(std::string type,double max,double price,double need,double productionRate);
void removeGoodType(std::string type);
std::vector<std::tuple<std::string,double,double,double,double,double> > getListGoods() { return listGoods;};
std::tuple<double,double,double,double,double> getGood(std::string type);
void addGood(std::string type,double value);
void removeGood(std::string type,double value);
std::tuple<std::string,double,double,double,double,double> getProducedGood();
//acess differents values of one ressource
double getQuantity(std::string type){ return std::get<0>(getGood(type));};
double getPrice(std::string type){ return std::get<2>(getGood(type));};
double getNeed(std::string type){ return std::get<3>(getGood(type));};
double getProductionRate(std::string type){ return std::get<4>(getGood(type));};
void setPrice(std::string type,double value);
void setQuantity(std::string type, double value);
void setNeed(std::string type, double value);
void setProductionRate(std::string type, double value);
std::vector<std::tuple<std::string,double,double,double,double,double> > getListGoodsFrom(std::string target);
void printInventory();
//sending goods
void sendGoodTo(std::string target, std::string type, double value);
//trading goods
void proposeTradeTo(std::string target, std::string type, double valueGood, double valueCurrency);
void acceptTradeFrom(std::string source, std::string type, double valueGood, double valueCurrency);
void refuseTradeFrom(std::string source, std::string type, double valueGood, double valueCurrency);
std::vector<std::tuple<std::string,std::string,double,double> > getProposedTrades() {return listProposedTrades;};
std::vector<std::tuple<std::string,double,double> > getProposedTradesTo(std::string target);
std::vector<std::tuple<std::string,std::string,double,double> > getReceivedTrades(){return listReceivedTrades;};
std::vector<std::tuple<std::string,double,double> > getReceivedTradesFrom(std::string source);
void killTradesTo(std::string source);
void killTradesFrom(std::string source);
////////////////////////////////////////////////
// This code has been automatically generated //
/////// Please do not modify it ////////////////
////////////////////////////////////////////////
Roman( void * );
void * fillPackage();
void sendVectorAttributes(int);
void receiveVectorAttributes(int);
////////////////////////////////////////////////
//////// End of generated code /////////////////
////////////////////////////////////////////////
};
} // namespace Epnet
#endif // __Roman_hxx__