File tree Expand file tree Collapse file tree 1 file changed +13
-16
lines changed
examples/sugarscape_g1mt/sugarscape_g1mt Expand file tree Collapse file tree 1 file changed +13
-16
lines changed Original file line number Diff line number Diff line change 1
1
import mesa
2
2
3
3
from .model import SugarscapeG1mt
4
- from .resource_agents import Spice , Sugar
4
+ from .resource_agents import Resource
5
5
from .trader_agents import Trader
6
6
7
7
sugar_dic = {4 : "#005C00" , 3 : "#008300" , 2 : "#00AA00" , 1 : "#00F800" }
@@ -21,9 +21,18 @@ def Agent_portrayal(agent):
21
21
"Color" : "#FF0A01" ,
22
22
}
23
23
24
- elif isinstance (agent , Sugar ):
25
- color = sugar_dic [agent .amount ] if agent .amount != 0 else "#D6F5D6"
26
- layer = 1 if agent .amount > 2 else 0
24
+ elif isinstance (agent , Resource ):
25
+ resource_type = "sugar" if agent .max_sugar > agent .max_spice else "spice"
26
+ if resource_type == "sugar" :
27
+ color = (
28
+ sugar_dic [agent .sugar_amount ] if agent .sugar_amount != 0 else "#D6F5D6"
29
+ )
30
+ layer = 1 if agent .sugar_amount > 2 else 0
31
+ else :
32
+ color = (
33
+ spice_dic [agent .spice_amount ] if agent .spice_amount != 0 else "#D6F5D6"
34
+ )
35
+ layer = 1 if agent .spice_amount > 2 else 0
27
36
return {
28
37
"Color" : color ,
29
38
"Shape" : "rect" ,
@@ -33,18 +42,6 @@ def Agent_portrayal(agent):
33
42
"h" : 1 ,
34
43
}
35
44
36
- elif isinstance (agent , Spice ):
37
- color = spice_dic [agent .amount ] if agent .amount != 0 else "#D6F5D6"
38
- layer = 1 if agent .amount > 2 else 0
39
- return {
40
- "Color" : color ,
41
- "Shape" : "rect" ,
42
- "Filled" : "true" ,
43
- "Layer" : 0 ,
44
- "w" : 1 ,
45
- "h" : 1 ,
46
- }
47
-
48
45
return {}
49
46
50
47
You can’t perform that action at this time.
0 commit comments