-
Notifications
You must be signed in to change notification settings - Fork 0
/
treaties.pde
101 lines (85 loc) · 2.4 KB
/
treaties.pde
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
enum TreatyVariable {
AGE,
OFFENCE,
DEFENCE,
UTILITY,
NEIGHBOURHOOD,
OFFENCE_INVESTMENT,
DEFENCE_INVESTMENT,
UTILITY_INVESTMENT,
ATTACK_INVESTMENT,
ATTACK_LAUNCHED,
ATTACK_AGAINST
};
enum TreatyOpCode {
EQ,
NEQ,
LT,
GT,
LEQ,
GEQ
}
class Treaty {
Agent treatyFrom;
Agent treatyTo;
TreatyInfo treatyInfo; //Treaty after MVP
Treaty(Agent treatyFrom, Agent treatyTo, TreatyInfo t) {
this.treatyFrom = treatyFrom;
this.treatyTo = treatyTo;
this.treatyInfo = t;
}
void Print() {
println(this.treatyFrom.getID(), this.treatyTo.getID(), this.treatyInfo.treatyName);
}
}
class TreatyResponse {
Treaty proposal;
boolean response;
TreatyResponse(Treaty proposal, boolean response) {
this.proposal = proposal;
this.response = response;
}
}
class TreatyInfo {
String treatyName; // name of treaty
String description; // description of how treaty works
TreatyVariable[] reqVars; // necessary agent parameters to define treaty condition
float[] matReqVars; // matrix of multipliers for agent parameters
TreatyOpCode[] auxiliary; // op code set
ActionType[] treatyCategory; // action(s) that treaty affects
TreatyInfo(String tn, String d, TreatyVariable[] rv, float[] mrv, TreatyOpCode[] aux, ActionType[] tc) {
this.treatyName = tn;
this.description = d;
this.reqVars = rv;
this.matReqVars = mrv;
this.auxiliary = aux;
this.treatyCategory = tc;
}
String what() {
return this.description;
}
}
//set of treaties that can be proposed
final TreatyInfo[] globalTreatyCache = new TreatyInfo[]{
new TreatyInfo("noUtil",
"a nice treaty",
new TreatyVariable[]{TreatyVariable.AGE},
new float[]{1, -1, 1, -3},
new TreatyOpCode[]{TreatyOpCode.GT, TreatyOpCode.LT},
new ActionType[]{ActionType.boostUtility}
),
new TreatyInfo("ageBig0UtilLess600",
"a test treaty",
new TreatyVariable[]{TreatyVariable.AGE, TreatyVariable.UTILITY},
new float[]{1, 0, 0, 0, 1, -600},
new TreatyOpCode[]{TreatyOpCode.GT, TreatyOpCode.LT},
new ActionType[]{ActionType.boostOffence}
),
new TreatyInfo("noAttacknoOffence",
"a cool treaty",
new TreatyVariable[]{TreatyVariable.OFFENCE_INVESTMENT, TreatyVariable.ATTACK_LAUNCHED},
new float[]{1, 0, -20, 0, 1, 0},
new TreatyOpCode[]{TreatyOpCode.LT, TreatyOpCode.EQ},
new ActionType[]{ActionType.boostOffence, ActionType.launchAttack}
),
};