-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.py
More file actions
43 lines (32 loc) · 804 Bytes
/
Copy pathserver.py
File metadata and controls
43 lines (32 loc) · 804 Bytes
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
import mesa
from mesa.visualization.modules import CanvasGrid
from mesa.visualization.UserParam import Slider
from mesa.visualization.ModularVisualization import ModularServer
from model import GridModel
def agent_portrayal(agent):
portrayal = {
"Shape": "circle",
"Filled": "true",
"Color": agent.color,
"stroke_color": "black",
"Layer": 1,
"r": 0.8
}
return portrayal
width = 10
height = 10
grid = CanvasGrid(agent_portrayal, width, height, 500, 500)
model_params = {
"width": width,
"height": height,
"num_agents": Slider("Agent Number", 10, 1, 10, 1)
}
server = ModularServer(
GridModel,
[grid],
"Random Walker Model",
model_params
)
server.port = 8521
if __name__ == "__main__":
server.launch()