@@ -259,14 +259,14 @@ namespace emp {
259259
260260 // / Retrieve a const reference to the organsim as the specified position.
261261 // / Same as operator[]; will trip assert if cell is not occupied.
262- const ORG & GetOrg (size_t id) const {
262+ ORG & GetOrg (size_t id) {
263263 emp_assert (pop[id] != nullptr , id); // Should not index to a null organism!
264264 return *(pop[id]);
265265 }
266266
267267 // / Retrieve a const reference to the organsim as the specified x,y coordinates.
268268 // / (currently used only in a grid world)
269- const ORG & GetOrg (size_t x, size_t y) const { return GetOrg (x+y*size_x); }
269+ ORG & GetOrg (size_t x, size_t y) { return GetOrg (x+y*size_x); }
270270
271271 // / Retrive a pointer to the contents of a speciefied cell; will be nullptr if the cell is
272272 // / not occupied.
@@ -448,7 +448,7 @@ namespace emp {
448448
449449 // / Reset the hardware for all organisms.
450450 void ResetHardware () {
451- for (Ptr<ORG> org : pop) { if (org) org->ResetHardware (); }
451+ for (Ptr<ORG> org : pop) { if (org) org->ResetHardware (); }
452452 }
453453
454454 // --- CALCULATE FITNESS ---
@@ -541,6 +541,8 @@ namespace emp {
541541 // / Get the id of a random *occupied* cell.
542542 size_t GetRandomOrgID ();
543543
544+ // / Get an organism from a random occupied cell.
545+ ORG & GetRandomOrg () { return *pop[GetRandomOrgID ()]; }
544546
545547 // --- POPULATION ANALYSIS ---
546548
0 commit comments