richelbilderbeek / djog_unos_2018

Project by the Uno's at DJOG 2018-2019: Nature Zen
GNU General Public License v3.0
6 stars 2 forks source link

Use biological constants #550

Open richelbilderbeek opened 5 years ago

richelbilderbeek commented 5 years ago

Depends on:

Is your feature request related to a problem? Please describe.

Currently, I see some magical constants:

  if ((m_type == agent_type::grass && m_health > 100.0) ||
      (m_type == agent_type::tree && m_health > 500.0) ||
      (m_type == agent_type::cow && m_health > 100.0) ||
      (m_type == agent_type::cactus && m_health > 100.0))

Describe the solution you'd like

Replace these by:

  if ((m_type == agent_type::grass && m_health > biology().get_grass_reproduction_health()) ||
      (m_type == agent_type::tree && m_health > biology().get_tree_reproduction_health()) ||
      (m_type == agent_type::cow && m_health > biology().get_cow_reproduction_health()) ||
      (m_type == agent_type::cactus && m_health > biology().get_cactus_reproduction_health()))

Something along the lines of:

assert(biology().get_grass_reproduction_health()) == 100.0)

Describe alternatives you've considered

None.

Additional context

There will be a follow-up to simplify the ifstatement :+1: