2021-03-13 17:41:38 +01:00
|
|
|
from model import GameMap
|
|
|
|
from mesa.visualization.modules import CanvasGrid
|
|
|
|
from mesa.visualization.ModularVisualization import ModularServer
|
|
|
|
|
|
|
|
|
2021-03-16 15:36:24 +01:00
|
|
|
def player_representation(agent):
|
2021-03-13 17:41:38 +01:00
|
|
|
portrayal = {"Shape": "circle",
|
|
|
|
"Filled": "true",
|
|
|
|
"Layer": 0,
|
|
|
|
"Color": "red",
|
|
|
|
"r": 0.5}
|
2021-03-16 15:36:24 +01:00
|
|
|
if agent.isBox:
|
|
|
|
portrayal["Color"] = "grey"
|
|
|
|
portrayal["Layer"] = 1
|
2021-03-13 17:41:38 +01:00
|
|
|
return portrayal
|
|
|
|
|
2021-03-16 15:36:24 +01:00
|
|
|
grid = CanvasGrid(player_representation, 10, 10, 500, 500)
|
2021-03-13 17:41:38 +01:00
|
|
|
server = ModularServer(GameMap,
|
|
|
|
[grid],
|
|
|
|
"Map",
|
|
|
|
{"x":10, "y":10, "boxes_number":5})
|
|
|
|
server.port = 8521
|
|
|
|
server.launch()
|