So I am making a sort of continuous evolutionary system in the Unity3D engine. Currently I have a DNA class that has values that gets applied to a Creature object on initializing e.g.:

public class DNA{
    public float maxSpeed;
    public float foodWeight;

    public DNA(float maxSpeed){
        this.maxSpeed = maxSpeed;
        this.foodWeight = foodWeight;

Where every Creature has a public DNA variable that gets set when instantiating a population of Creatures via a GameManager class. In this "ecosystem" I want to have the creatures crave for food and try to avoid the poison.

My question isn't about the reproducing or natural selection part, but more about what the best kind of data type for each object is. Since I want the project to have expandable amount of Creatures, sorts of food etc. Is the best way to handle all data via one GameManager, or should I seperate it in for example CreatureManager, FoodManager etc.?

Maybe a PopulationManager of some sorts?

Is the current setup for the DNA data optimal? Also, currently I have food and poison just as two prefabs and detect collision (and add or substract health whether it's food or poison via tag), wouldn't it be smarter to create a struct for food and poison so I can later on expand on this?

Sorry if any of the given information is unclear or a bit vague, please say so if this is the case! I would be glad to clarify and add any needed information. Thank you for reading through the entirety of my question, thanks for your time! :)

  • \$\begingroup\$ As far as I think you are on a right path. Lets supposed men and women are both human but behaves differently. So Human is different class/interface and Men and women are different class which inherits human class. \$\endgroup\$ – Saad Anees May 1 '19 at 6:13
  • \$\begingroup\$ @SaadAnees thanks for your thoughts on this! \$\endgroup\$ – Arne de Beer May 1 '19 at 12:55
  • 1
    \$\begingroup\$ I don't think this question defines one problem in enough detail for us to be able to offer good solutions. "wouldn't it be smarter to create a struct for food and poison so I can later on expand on this?"- if that makes sense to you, sure. You don't need our blessing to try it. Did you run into any particular problem putting this idea into practice? The more specific you can be about what you need to solve, the better the solutions we can offer. \$\endgroup\$ – DMGregory May 10 '19 at 10:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.