Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 31e78d1c authored by David Parsons's avatar David Parsons
Browse files

Add accessor indiv_by_rank in World and ExpManager

parent d16cde69
No related branches found
No related tags found
No related merge requests found
...@@ -653,6 +653,10 @@ Individual* ExpManager::indiv_by_id(int32_t id) const { ...@@ -653,6 +653,10 @@ Individual* ExpManager::indiv_by_id(int32_t id) const {
return world_->indiv_by_id(id); return world_->indiv_by_id(id);
} }
Individual* ExpManager::indiv_by_rank(int32_t rank) const {
return world_->indiv_by_id(rank);
}
/** /**
* Returns a list of all the individuals with their replication report * Returns a list of all the individuals with their replication report
*/ */
......
...@@ -112,6 +112,7 @@ class ExpManager : public Observer { ...@@ -112,6 +112,7 @@ class ExpManager : public Observer {
int32_t nb_indivs() const { return world()->nb_indivs(); } int32_t nb_indivs() const { return world()->nb_indivs(); }
Individual* best_indiv() const { return world()->best_indiv(); } Individual* best_indiv() const { return world()->best_indiv(); }
Individual* indiv_by_id(int32_t id) const; Individual* indiv_by_id(int32_t id) const;
Individual* indiv_by_rank(int32_t rank) const;
// Accessors to output manager stuff // Accessors to output manager stuff
int64_t backup_step() const { return output_m()->backup_step(); } int64_t backup_step() const { return output_m()->backup_step(); }
......
...@@ -490,4 +490,13 @@ Individual* World::indiv_by_id(int32_t id) const { ...@@ -490,4 +490,13 @@ Individual* World::indiv_by_id(int32_t id) const {
} }
return nullptr; return nullptr;
} }
Individual* World::indiv_by_rank(int32_t rank) const {
int32_t nb_indivs = width_ * height_;
for (int32_t i = 0 ; i < nb_indivs ; i++) {
if (grid_1d_[i]->individual()->rank() == rank)
return grid_1d_[i]->individual();
}
return nullptr;
}
} // namespace aevol } // namespace aevol
...@@ -90,6 +90,7 @@ class World ...@@ -90,6 +90,7 @@ class World
inline GridCell* grid(int16_t x, int16_t y) const; inline GridCell* grid(int16_t x, int16_t y) const;
inline Individual* indiv_at(int16_t x, int16_t y) const; inline Individual* indiv_at(int16_t x, int16_t y) const;
Individual* indiv_by_id(int32_t id) const; Individual* indiv_by_id(int32_t id) const;
Individual* indiv_by_rank(int32_t rank) const;
inline double** secretion_present_grid() const; inline double** secretion_present_grid() const;
inline double** secreted_amount_grid() const; inline double** secreted_amount_grid() const;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment