-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.py
45 lines (35 loc) · 1.24 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
43
44
45
from virtual_world import VirtualWorldModel
from mesa.visualization.modules import CanvasGrid, ChartModule
from mesa.visualization.ModularVisualization import ModularServer
def cell(agent):
portrayal = {'Shape': 'rect',
'Layer': 0,
'w': 1,
'h': 1,
'Filled': 'true'}
if agent.type == 'house':
portrayal['Color'] = '#C9160A'
elif agent.type == 'road':
portrayal['Color'] = '#D0DC19'
elif agent.type == 'trail':
portrayal['Color'] = '#C98C0A'
elif agent.type == 'forest':
portrayal['Color'] = '#237308'
elif agent.type == 'grass':
portrayal['Color'] = '#4ECA24'
elif agent.type == 'type1':
portrayal['Shape'] = 'circle'
portrayal['r'] = '0.7'
portrayal['Layer'] = 1
portrayal['Color'] = 'black'
elif agent.type == 'type2':
portrayal['Shape'] = 'circle'
portrayal['r'] = '0.7'
portrayal['Layer'] = 2
portrayal['Color'] = 'blue'
return portrayal
grid = CanvasGrid(cell, 50, 50, 600, 600)
server = ModularServer(VirtualWorldModel, [grid], "Virtual World", {
'N': 50, 'width': 50, 'height': 50})
server.port = 8000
server.launch()