Skip to content

Commit c29ced8

Browse files
authored
Fix Eat Sugarscape_g1mt (#20)
* - Add sugarcape_g1mt that is consistent with complexity tutorial - Include interactive version with single run, batch run and server options - Update .gitignore to ignore IDE environment files * - update eat function based on user identified bug in Complexity Explorer Tutorial - update Readme so batch run does not get an argument error - update run so data processing of batchrunner does not get a key error
1 parent 489aac8 commit c29ced8

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

examples/sugarscape_g1mt/Readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ To run the model a single instance of the model:
6363
To run the model with BatchRunner:
6464

6565
```
66-
$ python run.py
66+
$ python run.py -b
6767
```
6868

6969
To run the model interactively:

examples/sugarscape_g1mt/run.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def assess_results(results, single_agent):
1919
plt.plot(results_df["Step"], results_df["Trader"])
2020
plt.show()
2121
else:
22-
n = max(results_df["RunID"])
22+
n = max(results_df["RunId"])
2323
# Plot number of Traders
2424
for i in range(n):
2525
results_explore = results_df[results_df["RunId"] == i]

examples/sugarscape_g1mt/sugarscape_g1mt/trader_agents.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -322,23 +322,21 @@ def move(self):
322322
self.model.grid.move_agent(self, final_candidate)
323323

324324
def eat(self):
325-
"""
326-
Function for trader to consume sugar and spice in grid cell
327-
"""
328-
329325
# get sugar
330326
sugar_patch = self.get_sugar(self.pos)
331-
# eat sugar
327+
332328
if sugar_patch:
333-
self.sugar = self.sugar - self.metabolism_sugar + sugar_patch.amount
329+
self.sugar += sugar_patch.amount
334330
sugar_patch.amount = 0
331+
self.sugar -= self.metabolism_sugar
335332

336-
# get spice
333+
# get_spice
337334
spice_patch = self.get_spice(self.pos)
338-
# eat spice
335+
339336
if spice_patch:
340-
self.spice = self.spice - self.metabolism_spice + spice_patch.amount
337+
self.spice += spice_patch.amount
341338
spice_patch.amount = 0
339+
self.spice -= self.metabolism_spice
342340

343341
def maybe_die(self):
344342
"""

0 commit comments

Comments
 (0)