We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I was interested in knowing the number of soldiers in the ant population. So I played with the following changes:
Added the following to the bottom of colony.hpp:
uint32_t soldiersCount() { return std::count_if(ants.begin(), ants.end(), [](Ant& a) { return a.type == Ant::Type::Soldier; }); }
Changes to colony_renderer.hpp:
Added a soldiersCount variable:
uint32_t ants_count = 0; uint32_t soldiers_count = 0;
Changed updateData( ) to retrieve the soldiersCount:
ants_count = to<int32_t>(colony.ants.size()); soldiers_count = to<int32_t>(colony.soldiersCount());
And then changed the render( ) to show the soldiersCount and right-justify the pop_diff:
text.setCharacterSize(20); text.setFillColor(sf::Color::White); text.setPosition(position.x + padding, position.y); text.setString("Population " + toStr(soldiers_count) + "/" + toStr(ants_count)); target.draw(text); text.setCharacterSize(14); text.setFillColor(pop_diff >= 0 ? sf::Color::Green : sf::Color::Red); const std::string sign = (pop_diff >= 0 ? "+" : ""); text.setString("(" + sign + toStr(pop_diff) + " Ants over last 60s)"); // right justify sf::FloatRect bounds = text.getLocalBounds(); text.setPosition((position.x + population.width + padding) - bounds.width, position.y + 0.5f * padding); target.draw(text);
Kudos for writing this simulation - everybody who has seen it work has been fascinated.
The text was updated successfully, but these errors were encountered:
Thank you very much for sharing this! If you want you can create a pull request to add this into the project, I think it is a great idea.
Sorry, something went wrong.
No branches or pull requests
I was interested in knowing the number of soldiers in the ant population. So I played with the following changes:
Added the following to the bottom of colony.hpp:
Changes to colony_renderer.hpp:
Added a soldiersCount variable:
Changed updateData( ) to retrieve the soldiersCount:
And then changed the render( ) to show the soldiersCount and right-justify the pop_diff:
Kudos for writing this simulation - everybody who has seen it work has been fascinated.
The text was updated successfully, but these errors were encountered: