diff --git a/examples/sugarscape_g1mt/sugarscape_g1mt/model.py b/examples/sugarscape_g1mt/sugarscape_g1mt/model.py index 3f7c08d7..6e9629db 100644 --- a/examples/sugarscape_g1mt/sugarscape_g1mt/model.py +++ b/examples/sugarscape_g1mt/sugarscape_g1mt/model.py @@ -77,10 +77,13 @@ def __init__( model_reporters={ "Trader": lambda m: m.schedule.get_type_count(Trader), "Trade Volume": lambda m: sum( - len(a.trade_partners) for a in m.schedule.agents_by_type[Trader] + len(a.trade_partners) + for a in m.schedule.agents_by_type[Trader].values() ), "Price": lambda m: geometric_mean( - flatten([a.prices for a in m.schedule.agents_by_type[Trader]]) + flatten( + [a.prices for a in m.schedule.agents_by_type[Trader].values()] + ) ), }, agent_reporters={"Trade Network": lambda a: get_trade(a)}, @@ -140,7 +143,7 @@ def randomize_traders(self): puts traders in randomized list for step function """ - traders_shuffle = list(self.schedule.agents_by_type[Trader]) + traders_shuffle = list(self.schedule.agents_by_type[Trader].values()) self.random.shuffle(traders_shuffle) return traders_shuffle @@ -151,7 +154,7 @@ def step(self): and then randomly activates traders """ # step Resource agents - for resource in self.schedule.agents_by_type[Resource]: + for resource in self.schedule.agents_by_type[Resource].values(): resource.step() # step trader agents diff --git a/examples/wolf_sheep/wolf_sheep/scheduler.py b/examples/wolf_sheep/wolf_sheep/scheduler.py index a29a5a77..97424a55 100644 --- a/examples/wolf_sheep/wolf_sheep/scheduler.py +++ b/examples/wolf_sheep/wolf_sheep/scheduler.py @@ -25,7 +25,7 @@ def get_type_count( if type_class not in self.agents_by_type: return 0 count = 0 - for agent in self.agents_by_type[type_class]: + for agent in self.agents_by_type[type_class].values(): if filter_func is None or filter_func(agent): count += 1 return count