Skip to content

Commit

Permalink
Spatial EcoLab starting to work.
Browse files Browse the repository at this point in the history
  • Loading branch information
highperformancecoder committed Sep 11, 2024
1 parent a23d937 commit 486c6bf
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
1 change: 1 addition & 0 deletions models/ecolab_model.cc
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,7 @@ void SpatialModel::setGrid(size_t nx, size_t ny)
for (size_t i=0; i<numX; ++i)
for (size_t j=0; j<numY; ++j)
insertObject(makeId(i,j));
rebuildPtrLists();
}

void SpatialModel::generate(unsigned niter)
Expand Down
4 changes: 2 additions & 2 deletions models/ecolab_model.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ class SpatialModel: public ModelData, public graphcode::Graph<EcoLabCell>
public:
size_t makeId(size_t x, size_t y) const {return x%numX + numX*(y%numY);}
void setGrid(size_t nx, size_t ny);
graphcode::ObjectPtr<EcoLabCell> cell(size_t x, size_t y) {
return objects[makeId(x,y)];
EcoLabCell& cell(size_t x, size_t y) {
return *objects[makeId(x,y)];
}
void makeConsistent();
void generate(unsigned niter);
Expand Down
9 changes: 5 additions & 4 deletions models/spatial_ecolab.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,18 @@ def randomList(num, min, max):
ecolab.migration(nsp*[1e-5])

from plot import plot
from GUI import gui, statusBar, windows

def step():
ecolab.generate()
# ecolab.mutate()
# ecolab.condense()
ecolab.mutate()
#ecolab.condense()
nsp=len(ecolab.species)
statusBar.configure(text=f't={ecolab.tstep()} nsp:{nsp}')
# plot('No. species',ecolab.tstep(),nsp)
plot('No. species',ecolab.tstep(),nsp)
for i in range(numX):
for j in range(numY):
plot(f'Density({i},{j}',ecolab.tstep(),ecolab.cell(i,j).density()._properties, pens=ecolab.species()._properties)
plot(f'Density({i},{j})',ecolab.tstep(),ecolab.cell(i,j).density(), pens=ecolab.species())

gui(step)

Expand Down

0 comments on commit 486c6bf

Please sign in to comment.