MCPcopy Create free account
hub / github.com/devosoft/avida / IsWorldBoundary

Method IsWorldBoundary

avida-core/source/main/cMultiProcessWorld.cc:228–256  ·  view source on GitHub ↗

! Returns true if the given cell is on the boundary of the world, false otherwise. */

Source from the content-addressed store, hash-verified

226/*! Returns true if the given cell is on the boundary of the world, false otherwise.
227 */
228bool cMultiProcessWorld::IsWorldBoundary(const cPopulationCell& cell) {
229 if(GetConfig().BIRTH_METHOD.Get()==POSITION_OFFSPRING_RANDOM) {
230 int x, y;
231 cell.GetPosition(x,y);
232
233 // if this cell isn't on the boundary of this world, then there's no way that
234 // it can cause a migration, regardless of world geometry.
235 if(!((x == 0) || (x == (GetConfig().WORLD_X.Get()-1)) || (y == 0) || (y == (GetConfig().WORLD_Y.Get()-1)))) {
236 return false;
237 }
238
239 switch(GetConfig().WORLD_GEOMETRY.Get()) {
240 case nGeometry::GRID: { // bounded grid: prevent the universe boundary cells from causing migrations.
241 int uni_x = x + GetConfig().WORLD_X.Get() * m_universe_x;
242 int uni_y = y + GetConfig().WORLD_Y.Get() * m_universe_y;
243 return !((uni_x == 0) || (uni_x == (GetConfig().WORLD_X.Get() * m_universe_dim-1))
244 || (uni_y == 0) || (uni_y == (GetConfig().WORLD_Y.Get() * m_universe_dim-1)));
245 }
246 case nGeometry::TORUS: { // torus: this always results in a migration (because, if we reached
247 // here, we know the cell is on the boundary).
248 return true;
249 }
250 default: {
251 GetDriver().RaiseFatalException(-1, "Only bounded grid and toroidal geometries are supported for cell migration.");
252 }
253 }
254 }
255 return false;
256}
257
258
259/*! Process post-update events.

Callers

nothing calls this directly

Calls 3

GetMethod · 0.45
GetPositionMethod · 0.45
RaiseFatalExceptionMethod · 0.45

Tested by

no test coverage detected