Code Monkey home page Code Monkey logo

ecosystem-simulator's Introduction

Ecosystem Simulator

This project consists on an ecosystem simulator with trees, food and animals with the goal of having thousands of entities on screen.

Controls

  • WASD: Camera movement
  • Shift + WASD: Faster speed on camera movement
  • Left mouse: Select animal (Click outside to deselect)

Download

The prototype is available for download. Get the latest version on the releases section.

Author

The author and developer of this project is Pablo Galve.

License

This project is released under the MIT License

ecosystem-simulator's People

Contributors

pablogalve avatar

Watchers

 avatar  avatar

ecosystem-simulator's Issues

Multi-threading

Add multi-threading

Main thread stable at 30 FPS
Secondary thread to calculate pathfinding and other expensive operations that are not urgent for the next frame

[Reproduction] Implement r and K reproduction strategies

r: animal that has a short lifespan and its strategy is to reproduce as many times as possible and have the maximum amount of babies. Example: Mouse

K: animal that has a long lifespan and its strategy is to reproduce only a couple of times, but to have strong babies that are more likely to survive
Example: Elephant

Methodology

Write the documentation for the Methodology section

Make sure that trees don't spawn on the same position

At this moment, the trees can spawn on any green area, but they should be only able to spawn on areas where there are no trees.

Possible solution:
Represent the world into a 2d map, so that it's possible to implement a two-dimensional hashmap/dictionary which holds the coordinates as key, and true/false if there is a tree on the area. Alternatively, it can hold an int (0,1,2) if the areas can hold X amount of trees with certain density.

Newborns are spawned with an adult size

Actual behavior

Newborns are spawned with an adult size

Expected behavior

Newborns should spawn at a reduced size, equivalent of 1 year of life

Thoughts

Maybe OnSpawn() is not being called correctly?

Add carnivore animals

Carnivores are similar to herbivores in the sense that have the same stats: hunger, reproduction urge, etc.
However, when they are hungry they look to hunt other animals instead of looking for fruits or vegetables.

Reproduction system for animals

  1. When animals are adults, they should have a reproduction urge stat that increases over time.
  2. When their reproduction urge is great enough and other stats with greater priority are met (e.g. hunger and survival), they start looking for a mate of the opposite sex.
  3. If a match is found, the female gets pregnant and becomes unavailable. The gestation period begins.
  4. The pregnant female reduces its skills (lower speed, more hunger, etc)
  5. Once gestation period has come to an end, a baby from the same species is born.

Animals should search within a radius, and (if possible) use a navMesh function instead of Vector3.Distance

  • Vector3.Distance works, but it can be slow given that internally it does a square root (sqrt). Use the squared distance instead to avoid expensive operations.

If an optimized method similar to Vector3.Distance exists using NavMesh, then do this.
Else if an optimized method (in general) similar to Vector3.Distance but without "sqrt" exists, use this

Potential information:
https://stackoverflow.com/questions/50153370/how-to-get-the-closest-object-in-the-navmesh-and-making-the-agent-move-towards-i

  • Levy walk:
    Example in C++
a=1 (m?)
b=5000-10000 (m?)

levy(a,b,mu){
        double u = random_within(0,1);
        double range = pow(b,1-mu) - pow(a, 1-mu);
        double base = range*u + pow(a,(1-mu));
        out = pow(base,1/(1-mu));
return(out)   
}

Implement Level of Detail (LOD)

Currently there can be around 10-15.000 trees at a approximately 15-25fps
image

The next obstance is reduce the impact that rendering has in the simulation. If rendering had 0 impact, the simulation would run at 60 fps with some spikes to 20fps
image

Navmesh and pathfinding

  • Create a navmesh on the scene
  • Create a cube that moves around the scene using the navmesh and pathfinding

Introduction

Write the documentation for the Introduction section

KeyNotFoundException: The given key was not present in the dictionary.

The error appears on multiple different lines, but it's (most likely) related

image

EntityManager.cs:72

System.Collections.Generic.Dictionary`2[TKey,TValue].get_Item (TKey key) (at <695d1cc93cca45069c528c15c9fdd749>:0)
EntityManager.DeleteEntity () (at Assets/Scripts/Entities/EntityManager.cs:72)
EntityManager.DeleteEntities (System.Int32 maxOfEachTypeToDeleteInThisFrame) (at Assets/Scripts/Entities/EntityManager.cs:94)
EntityManager.LateUpdate () (at Assets/Scripts/Entities/EntityManager.cs:59)

EntityManager.cs:126

System.Collections.Generic.Dictionary`2[TKey,TValue].get_Item (TKey key) (at <695d1cc93cca45069c528c15c9fdd749>:0)
EntityManager+<GrowOrDie>d__19.MoveNext () (at Assets/Scripts/Entities/EntityManager.cs:126)
UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at <3be1a7ff939c43f181c0a10b5a0189ac>:0)
UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
<GrowOrDie>d__19:MoveNext() (at Assets/Scripts/Entities/EntityManager.cs:144)
UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)

Camera control

The user should be able to move the camera around the world

Tree basic system

  • Trees grow with time (it should be possible to see visually how they grow)
  • When a tree is old enough, it can reproduce and generate a seed / baby tree. The seed will be placed randomly in a radius of x metres from the parent tree
  • The seed will be able to grow only on the same type of bioma

Food is not deleted

What happens now

An animal eat food, but the food doesn't get removed or gets removed in 5-10 seconds. It happens both to herbivores and carnivores. Most likely because of UUIDs

Expected behavior

When an animal eats food, the food should get deleted either instantly or in less than 1 second

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.