-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathserver.py
42 lines (35 loc) · 1.86 KB
/
server.py
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
import mesa
#from mesa.visualization.modules import CanvasGrid
from mesa.visualization.modules import ChartModule
from mesa.visualization.UserParam import UserSettableParameter
#from mesa.visualization.modules import TextElement
from mesa.visualization.ModularVisualization import ModularServer
#from mesa.visualization.TextVisualization import TextData
#from mesa.visualization.TextVisualization import TextVisualization
from court.model import CourtModel
chart1 = ChartModule([
{"Label": "successful", "Color": "#7bb36e"},{"Label": "failed", "Color": "#c66657"},{"Label": "total", "Color": "#56bfdf"}],
data_collector_name='datacollector',
canvas_height=300, canvas_width=300
)
chart2 = ChartModule([
{"Label": "Gini", "Color": "#56bfdf"}],
data_collector_name='datacollector',
canvas_height=300, canvas_width=300
)
server = ModularServer(
CourtModel,
[chart1,chart2],
name="CourtModel",
model_params={
"juror_count": UserSettableParameter('slider', "Number of jurors", 20, 10, 100, 1,
description="Choose how many Juror agents to include in the model"),
"token_count": UserSettableParameter('slider', "Number of tokens", 40, 10, 400, 1,
description="Choose how many tokens in supply, tokens are split evenly among jurors at initialization."),
"threshold": UserSettableParameter('slider', "Belief Threshold", 1, 0.25, 5, 0.25,
description="Agents must sample within this many standard deviations from the true value to be coherent"),
"penalty_pct": UserSettableParameter('slider', "Dispensation Percentage", 0.1, 0.01, 1, 0.01,
description="Percentage of activated tokens which are redistributed from incoherent jurors to coherent")
})
server.port = 8521
server.launch()