@@ -15,20 +15,19 @@ def portray(g):
15
15
"trader" : {"x" : [], "y" : [], "c" : "tab:red" , "marker" : "o" , "s" : 10 },
16
16
}
17
17
18
- for i in range (g .width ):
19
- for j in range (g .height ):
20
- content = g ._grid [i ][j ]
21
- for agent in content :
22
- if isinstance (agent , Trader ):
23
- layers ["trader" ]["x" ].append (i )
24
- layers ["trader" ]["y" ].append (j )
18
+ # TODO update to Mesa 2.0 API
19
+ for content , i , j in g .coord_iter ():
20
+ for agent in content :
21
+ if isinstance (agent , Trader ):
22
+ layers ["trader" ]["x" ].append (i )
23
+ layers ["trader" ]["y" ].append (j )
24
+ else :
25
+ # Don't visualize resource with value <= 1.
26
+ value = agent .amount if agent .amount > 1 else np .nan
27
+ if isinstance (agent , Sugar ):
28
+ layers ["sugar" ][i ][j ] = value
25
29
else :
26
- # Don't visualize resource with value <= 1.
27
- value = agent .amount if agent .amount > 1 else np .nan
28
- if isinstance (agent , Sugar ):
29
- layers ["sugar" ][i ][j ] = value
30
- else :
31
- layers ["spice" ][i ][j ] = value
30
+ layers ["spice" ][i ][j ] = value
32
31
return layers
33
32
34
33
fig = Figure ()
0 commit comments