nkremerh / sugarscape

Development repository for the Digital Terraria Lab implementation of the Sugarscape agent-based societal simulation.
https://github.com/digital-terraria-lab/sugarscape
MIT License
7 stars 12 forks source link

Moves instantiation of all cells from addSugarPeak() and addSpicePeak()… #30

Closed colinhanrahan closed 8 months ago

colinhanrahan commented 8 months ago

…to Environment constructor, removes now unused placeCell() definition.

The Environment constructor currently fills grid with Nones, and addSugarPeak() and addSpicePeak() both have checks to instantiate default Cells outside of the peak shape if self.environment.findCell(i, j) == None. addSugarPeak() and addSpicePeak() should only add sugar and spice peaks as it says in their names, not create the empty grid cells too. It doesn't make sense to replace grid Nones with Cells in both addSugarPeak() and addSpicePeak(). It's more intuitive to instantiate the Cell objects in the Environment constructor.

*I did have to import cell to environment, but I think that makes sense given that grid stores Cells.

nkremerh commented 8 months ago

Great catch! This inspired me to write an alternative implementation which has the same complexity class but is a bit cleaner.