forked from SOMAS2020/SOMAS2020
-
Notifications
You must be signed in to change notification settings - Fork 0
/
params.go
206 lines (200 loc) · 6.53 KB
/
params.go
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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
package main
import (
"flag"
"github.com/SOMAS2020/SOMAS2020/internal/common/config"
"github.com/SOMAS2020/SOMAS2020/internal/common/shared"
)
var (
//config.Config
maxSeasons = flag.Uint(
"maxSeasons",
100,
"The maximum number of 1-indexed seasons to run the game.",
)
maxTurns = flag.Uint(
"maxTurns",
100,
"The maximum numbers of 1-indexed turns to run the game.",
)
initialResources = flag.Float64(
"initialResources",
100,
"The default number of resources at the start of the game.",
)
initialCommonPool = flag.Float64(
"initialCommonPool",
100,
"The default number of resources in the common pool at the start of the game.",
)
costOfLiving = flag.Float64(
"costOfLiving",
10,
"Subtracted from an islands pool before the next turn.\n"+
"This is the simulation-level equivalent to using resources to stay \n"+
"alive (e.g. food consumed). These resources are permanently consumed and do \n"+
" NOT go into the common pool. Note: this is NOT the same as the tax",
)
minimumResourceThreshold = flag.Float64(
"minimumResourceThreshold",
5,
"The minimum resources required for an island to not be in Critical state.",
)
maxCriticalConsecutiveTurns = flag.Uint(
"maxCriticalConsecutiveTurns",
3,
"The maximum consecutive turns an island can be in the critical state.",
)
foragingDeerMaxPerHunt = flag.Uint(
"foragingMaxDeerPerHunt",
4,
"Max possible number of deer on a single hunt (regardless of number of participants).",
)
foragingDeerIncrementalInputDecay = flag.Float64(
"foragingDeerIncrementalInputDecay",
0.8,
"Determines decay of incremental input cost of hunting more deer.",
)
foragingDeerBernoulliProb = flag.Float64(
"foragingDeerBernoulliProb",
0.95,
"`p` param in D variable (see foraging README). Controls prob of catching a deer or not.",
)
foragingDeerExponentialRate = flag.Float64(
"foragingDeerExponentialRate",
1,
"`lambda` param in W variable (see foraging README). Controls distribution of deer sizes.",
)
foragingDeerResourceMultiplier = flag.Float64(
"foragingDeerResourceMultiplier",
1,
"scalar value that adjusts returns to be in a range that is commensurate with cost of living, salaries etc.",
)
foragingDeerDistributionStrategy = flag.Int(
"foragingDeerDistributionStrategy",
int(shared.InputProportionalSplit),
shared.HelpResourceDistributionStrategy(),
)
foragingDeerMaxPopulation = flag.Uint(
"foragingDeerMaxPopulation",
12,
"Max possible deer population.",
)
foragingDeerGrowthCoefficient = flag.Float64(
"foragingDeerGrowthCoefficient",
0.4,
"Scaling parameter used in the population model. Larger coeff => deer pop. regenerates faster.",
)
foragingFishMaxPerHunt = flag.Uint(
"foragingMaxFishPerHunt",
6,
"Max possible catch (num. fish) on a single expedition (regardless of number of participants).",
)
foragingFishingIncrementalInputDecay = flag.Float64(
"foragingFishingIncrementalInputDecay",
0.8,
"Determines decay of incremental input cost of catching more fish.",
)
foragingFishingMean = flag.Float64(
"foragingFishingMean",
0.9,
"Determines mean of normal distribution of fishing return (see foraging README)",
)
foragingFishingVariance = flag.Float64(
"foragingFishingVariance",
0.2,
"Determines variance of normal distribution of fishing return (see foraging README)",
)
foragingFishingResourceMultiplier = flag.Float64(
"foragingFishingResourceMultiplier",
1,
"scalar value that adjusts returns to be in a range that is commensurate with cost of living, salaries etc.",
)
foragingFishingDistributionStrategy = flag.Int(
"foragingFishingDistributionStrategy",
int(shared.EqualSplit),
shared.HelpResourceDistributionStrategy(),
)
// config.DisasterConfig
disasterXMin = flag.Float64(
"disasterXMin",
0,
"Min x bound of archipelago (bounds for possible disaster).",
)
disasterXMax = flag.Float64(
"disasterXMax",
10,
"Max x bound of archipelago (bounds for possible disaster).",
)
disasterYMin = flag.Float64(
"disasterYMin",
0,
"Min y bound of archipelago (bounds for possible disaster).",
)
disasterYMax = flag.Float64(
"disasterYMax",
10,
"Max y bound of archipelago (bounds for possible disaster).",
)
disasterGlobalProb = flag.Float64(
"disasterGlobalProb",
0.1,
"Bernoulli 'p' param. Chance of a disaster occurring.",
)
disasterSpatialPDFType = flag.Int(
"disasterSpatialPDFType",
0,
shared.HelpSpatialPDFType(),
)
disasterMagnitudeLambda = flag.Float64(
"disasterMagnitudeLambda",
1,
"Exponential rate param for disaster magnitude",
)
)
func parseConfig() config.Config {
flag.Parse()
deerConf := config.DeerHuntConfig{
//Deer parameters
MaxDeerPerHunt: *foragingDeerMaxPerHunt,
IncrementalInputDecay: *foragingDeerIncrementalInputDecay,
BernoulliProb: *foragingDeerBernoulliProb,
ExponentialRate: *foragingDeerExponentialRate,
ResourceMultiplier: *foragingDeerResourceMultiplier,
DistributionStrategy: shared.ParseResourceDistributionStrategy(*foragingDeerDistributionStrategy),
MaxDeerPopulation: *foragingDeerMaxPopulation,
DeerGrowthCoefficient: *foragingDeerGrowthCoefficient,
}
fishingConf := config.FishingConfig{
// Fish parameters
MaxFishPerHunt: *foragingFishMaxPerHunt,
IncrementalInputDecay: *foragingFishingIncrementalInputDecay,
Mean: *foragingFishingMean,
Variance: *foragingFishingVariance,
ResourceMultiplier: *foragingFishingResourceMultiplier,
DistributionStrategy: shared.ParseResourceDistributionStrategy(*foragingFishingDistributionStrategy),
}
foragingConf := config.ForagingConfig{
DeerHuntConfig: deerConf,
FishingConfig: fishingConf,
}
disasterConf := config.DisasterConfig{
XMin: *disasterXMin,
XMax: *disasterXMax, // chosen quite arbitrarily for now
YMin: *disasterYMin,
YMax: *disasterYMax,
GlobalProb: *disasterGlobalProb,
SpatialPDFType: shared.ParseSpatialPDFType(*disasterSpatialPDFType),
MagnitudeLambda: *disasterMagnitudeLambda,
}
return config.Config{
MaxSeasons: *maxSeasons,
MaxTurns: *maxTurns,
InitialResources: shared.Resources(*initialResources),
InitialCommonPool: shared.Resources(*initialCommonPool),
CostOfLiving: shared.Resources(*costOfLiving),
MinimumResourceThreshold: shared.Resources(*minimumResourceThreshold),
MaxCriticalConsecutiveTurns: *maxCriticalConsecutiveTurns,
ForagingConfig: foragingConf,
DisasterConfig: disasterConf,
}
}