added sprites and made them render as agents in visualisation

This commit is contained in:
Niebby 2021-03-28 15:23:14 +02:00
parent 020b1aa6a1
commit b39c20da5f
3 changed files with 4 additions and 7 deletions

View File

@ -4,14 +4,11 @@ from mesa.visualization.ModularVisualization import ModularServer
def player_representation(agent): def player_representation(agent):
portrayal = {"Shape": "circle", portrayal = {"Shape": "sprites/hero.png",
"Filled": "true", "Layer": 1}
"Layer": 0,
"Color": "red",
"r": 0.5}
if agent.isBox: if agent.isBox:
portrayal["Color"] = "grey" portrayal["Shape"] = "sprites/box.png"
portrayal["Layer"] = 1 portrayal["Layer"] = 0
return portrayal return portrayal
grid = CanvasGrid(player_representation, 10, 10, 500, 500) grid = CanvasGrid(player_representation, 10, 10, 500, 500)

BIN
sprites/box.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 153 B

BIN
sprites/hero.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 221 B