Skip to content

Commit 8e9ed05

Browse files
committed
Merge branch 'new_spaces' of https://github.com/quaquel/mesa-examples into new_spaces
2 parents 65fc178 + 322023b commit 8e9ed05

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

examples/hotelling_law/hotelling_law/agents.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,11 +175,15 @@ def determine_preferred_store(self):
175175
for store in stores:
176176
# Calculate score based on consumer preference
177177
if consumer_preference == "proximity":
178-
score = self.euclidean_distance(self.cell.coordinate, store.cell.coordinate)
178+
score = self.euclidean_distance(
179+
self.cell.coordinate, store.cell.coordinate
180+
)
179181
elif consumer_preference == "price":
180182
score = store.price
181183
else: # Default case includes both proximity and price
182-
score = store.price + self.euclidean_distance(self.cell.coordinate, store.cell.coordinate)
184+
score = store.price + self.euclidean_distance(
185+
self.cell.coordinate, store.cell.coordinate
186+
)
183187

184188
# Update the list of best stores if a new minimum score is found
185189
if score < min_score:

examples/hotelling_law/hotelling_law/model.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ def _initialize_agents(self):
190190
# Randomly place agents on the grid for a grid environment.
191191
x = self.random.randrange(self.grid.dimensions[0])
192192
y = self.random.randrange(self.grid.dimensions[1])
193-
agent.cell = self.grid[(x,y)]
193+
agent.cell = self.grid[(x, y)]
194194

195195
# Place consumer agents
196196
for _ in range(self.num_consumers):
@@ -200,7 +200,7 @@ def _initialize_agents(self):
200200
# Place consumer randomly on the grid
201201
x = self.random.randrange(self.grid.dimensions[0])
202202
y = self.random.randrange(self.grid.dimensions[1])
203-
consumer.cell = self.grid[(x,y)]
203+
consumer.cell = self.grid[(x, y)]
204204

205205
# Method to advance the simulation by one step.
206206
def step(self):

0 commit comments

Comments
 (0)