-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
49 lines (42 loc) · 1.71 KB
/
main.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
46
47
48
49
import sys
sys.path.append('Additional_scenarious/prova_0')
from model import FoodModel
from mesa.visualization.modules import CanvasGrid
from mesa.visualization.ModularVisualization import ModularServer
from mesa.visualization.UserParam import UserSettableParameter
# This is a sample Python script.
# Press Maiusc+F10 to execute it or replace it with your code.
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.
def agent_portrayal(agent):
portrayal = {"Shape": "rect",
"Color": "Color",
"Filled": "true",
"Layer": 0,
"w": 0.5,
"h": 0.5}
if agent.type == "creature":
portrayal = {"Shape": "rect",
"Color": "red",
"Filled": "true",
"Layer": 0,
"w": 0.5,
"h": 0.5}
else:
portrayal = {"Shape": "circle",
"Color": "green",
"Filled": "true",
"Layer": 1,
"r": 0.2}
return portrayal
# Press the green button in the gutter to run the script.
if __name__ == '__main__':
#empty_model = FoodModel(10,10,10)
grid = CanvasGrid(agent_portrayal, 100, 100, 500, 500)
server = ModularServer(FoodModel,
[grid],
"Food Model",
{"N": UserSettableParameter("slider", "Creature number", 5, 0, 200, 1), "nf": UserSettableParameter("slider", "Food number", 5, 0, 200, 1), "width": 10, "height": 10})
server.port = 8521 # The default
server.launch()
# See PyCharm help at https://www.jetbrains.com/help/pycharm/
#prova