@@ -18,7 +18,7 @@ def __init__(self, num_agents=7, num_nodes=10):
1818 self .num_agents = num_agents
1919 self .num_nodes = num_nodes if num_nodes >= self .num_agents else self .num_agents
2020 self .G = nx .erdos_renyi_graph (n = self .num_nodes , p = 0.5 )
21- self .grid = mesa .spaces .Network (self .G , random = self .random , capacity = 1 )
21+ self .grid = mesa .experimental . cell_space .Network (self .G , random = self .random , capacity = 1 )
2222
2323 self .datacollector = mesa .DataCollector (
2424 model_reporters = {"Gini" : compute_gini },
@@ -47,24 +47,24 @@ def run_model(self, n):
4747 self .step ()
4848
4949
50- class MoneyAgent (mesa .spaces .CellAgent ):
50+ class MoneyAgent (mesa .experimental . cell_space .CellAgent ):
5151 """An agent with fixed initial wealth."""
5252
5353 def __init__ (self , model ):
5454 super ().__init__ (model )
5555 self .wealth = 1
5656
5757 def give_money (self ):
58- neighbors = [agent for agent in self .cell .neighborhood () .agents if not self ]
58+ neighbors = [agent for agent in self .cell .neighborhood .agents if not self ]
5959 if len (neighbors ) > 0 :
6060 other = self .random .choice (neighbors )
6161 other .wealth += 1
6262 self .wealth -= 1
6363
6464 def step (self ):
65- empty_neighbors = [cell for cell in self .cell .neighborhood () if cell .is_empty ]
65+ empty_neighbors = [cell for cell in self .cell .neighborhood if cell .is_empty ]
6666 if empty_neighbors :
67- self .move_to ( self .random .choice (empty_neighbors ) )
67+ self .cell = self .random .choice (empty_neighbors )
6868
6969 if self .wealth > 0 :
7070 self .give_money ()
0 commit comments