Skip to content
This repository has been archived by the owner on Sep 20, 2023. It is now read-only.

There is a maximum size a player can reach #726

Closed
TheoPannetier opened this issue Feb 22, 2023 · 1 comment
Closed

There is a maximum size a player can reach #726

TheoPannetier opened this issue Feb 22, 2023 · 1 comment
Assignees
Labels
junior Suitable for junior devs

Comments

@TheoPannetier
Copy link
Contributor

TheoPannetier commented Feb 22, 2023

Context

Players are so far able to reach disproportionate sizes by continuously eating the same weaker player.
This may no longer present an issue once we have some buffer time between two successive collisions + growth (e.g. #695), but for now it would be best to cap a player's max size to a reasonable* size. Rm later on if appropriate.

*you decide on what's reasonable!

Test

#ifdef FIX_ISSUE_726
  // (726) There is a maximum size a player can reach
  {
    player p;
    // How many growth cycles to max size?
    const double init_size = p.get_diameter();
    const double max_size = p.get_max_size();
    const double diff_size = max_size - init_size;
    assert(diff_size > 0);
    const double growth_factor = p.get_growth_factor();
    const int nb_cycles = static_cast<int>(std::ceil(diff_size / growth_factor));

    for (int i = 0; i < nb_cycles; i++)
    {
      p.grow();
    }
    p.grow(); // to be sure we should exceed max size
    assert(p.get_diameter() == max_size);
  }
#endif // FIX_ISSUE_726
@TheoPannetier TheoPannetier added the junior Suitable for junior devs label Feb 22, 2023
@TheoPannetier TheoPannetier self-assigned this Feb 22, 2023
TheoPannetier pushed a commit that referenced this issue Feb 22, 2023
TheoPannetier pushed a commit that referenced this issue Feb 22, 2023
@TheoPannetier
Copy link
Contributor Author

Done!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
junior Suitable for junior devs
Projects
None yet
Development

No branches or pull requests

1 participant