Giter Site home page Giter Site logo

simbiosis's Introduction

Hi ๐Ÿ‘‹! My name is ProtocolPav

streak graph languages graph


My Knowledge

python logo docker logo javascript logo typescript logo html5 logo react logo

tailwindcss logo nextjs logo nginx logo googlecloud logo amazonwebservices logo linux logo


Snake animation

simbiosis's People

Watchers

 avatar  avatar

simbiosis's Issues

Creature vision should be improved

A creature should randomly choose the direction in which it looks at. It would either be in front, to the left, or to the right of it.
This could be determined by its genes, but could also be just a random thing.

Creatures should also be able to discern what they see. Either:

  • Other species
  • Food
  • Same species
    And react accordingly to each.

Configuration for Food

Food should be allowed to be configured in the config file.
These are the options:

  • Cluster Spawn Chance: The chance that a new food cluster will spawn somewhere on the map
  • Food spawn type: Either 'chance' or 'timed'
  • Chance will randomly decide whether to spawn a food in a cluster every tick
  • Timed will wait a certain amount of ticks before spawning food
  • Food energy value: how much energy food can give

Perhaps I can add so that creatures can sometimes "pick up" food and drop it on collision, and that is how new clusters spawn.

New Movement [Attempt 4]

Attempt 3 did not work out, as it created lag since I was constantly saving CreatureBodyParts. The game became unplayable.

A new attempt at tackling the issue is the following:

  • I will move the creature just like I do now. Take the last bodypart, and move it to the front.
  • I will then move the entire rest of the body closer to the front of the body. This requires an algorithm for each body part to be moved to the same place relative to the head.

New Movement [attempt 3]

This is new movement which will be re-done. This is to comply with framerate independence.

I have decided to go back to the first attempt, as it will be easier to fix this.

When the creature moves, I will save the following information about it:

  • Position of the head
  • Position of every turning point
  • Direction the head & each turning point is facing

When drawing, rather than drawing one big rect joining the turning point to the end, I will instead take the length and draw one square for each length to join them. This way I also have bodyparts which I can use for collisions.

Issues

Issue when the body does not exactly connect to the head.

Issue when the body does not exactly connect to the head.

Rare occurrence when the body does actually connect to the head. This is due to the fact that the head is moving, and sometimes the rounding of the body is not done correctly

Rare occurrence when the body does actually connect to the head. This is due to the fact that the head is moving, and sometimes the rounding of the body is not done correctly

Issue when the body does not connect to the turning points

Issue when the body does not connect to the turning points

I have also noticed that in the first attempt the creature also gets shorter over time. This can be fixed with the same implementation as in Attempt 2.

I will remove the Tail as a value that I track. What is important to note, is that currently in Attempt 1 and 2, the tail is also used to track if turning points have been passed. This means that I must replace that with something else. What I will replace it with is checking the length between each turning point. I start with the head to the turning point, then on and on. If at any point the length exceeds the length of the creature, then all turning points after it are wiped.

I will also be replacing the get_full_body function. Instead I will be storing the full body in a list of CreatureBodyParts, which each of them will also store a facing attribute in them. I will create a new function which calculates and sets the list to the new body. Then when drawing, I will take that body and draw it one by one. The function also saves each CreatureBodyPart into the collisions dict.

Implement KD Tree Algorithm

Currently, for Collision detection between both Food and Creatures, I have had 2 iterations of this system.
In the first one, the creatures would search through the entire world to find if it is colliding. This was fine, until a certain number of creatures was reached.
I then split the world up into Quadrants, which improved this. Rather than searching the entire world, the creature would only search within its own quadrant for any collisions, which brought down search times by a lot.

From my research, the most efficient algorithm would be a KD-Tree algorithm.

Hover over creature to see genes

When your mouse hovers over a creature, you will see its genes on the side of the screen. Every gene's acronym and its value.
e.g:

  • EPS = 3.48322
  • LEN = 40.0

System Configuration

Have a config file where the user can change it and configure the environment.
This would include stuff like:

  • The mutation factor. How much a gene will mutate.
  • Mutation chances, what chance is there for a gene to mutate?
  • How much food spawns
  • How many initial species/creatures there are
  • And more...

Different creature reproduction

Currently, the only way for a species to evolve is for 2 creatures to collide, and hope that one of them gives birth.
I still wish to keep that, however from testing the simulation I have noticed it takes a long time for evolution to happen. So I am thinking of more ways for creatures to give birth.

There could be a gene for asexual reproduction. If the creature reproduces asexually, then it will lay an egg when a certain condition is met, like for example having double the energy to birth. Laying an egg will expend birthing energy. The egg will have identical genes to its parent, but will obviously have a chance for mutation.
Otherwise, the creature will birth only when colliding. At that point, both the creature's genes will be combined. Added together, then divided by 2. Or some other algorithm. The baby will also be able to have mutations though.

New Camera Drawing algorithm

Draw everything onto the camera's surface, and then scale that surface to fit whatever I need. I can also move that surface as needed.

Globalize entity IDs

Instead of making separate IDs for food and creatures, make IDs for the BaseEntity class, which would remove any confusion

Phaeromones

Creatures should be able to create phaeromones.

These would be released to help lead other creatures to food sources

Only creatures of the same species follow the phaeromones

Better Collisions

Perhaps I could find an algorithm to hash every creature's coordinates. Or store their coordinates.
Then when checking collisions, I could check that coordinate and see if there is multiple entries in the list.

More reactions

Add more reaction chances which are based on what happened before. For example, if the creature eats food, it'll turn. If it sees more food, itll turn again, but if it stops seeing food, itll turn back towards food.

Add a "go towards" reaction.

More ideas needed

Separate class for Creature Brain

This could have all of the probabilities for turning, and thus have a different chance of mutation.
Also, the Brain would control all the decisions, perhaps even having a small memory?

Expand creature Phenotype

Right now, there are three characteristics that can change the way a creature looks:

  • Length (determined live in the game, but the maximum length is determined via genetics)
  • Colour
  • Head Colour

I can expand this by using textures to draw the body. The creature keeps its body as is, but rather than drawing rectangles, i will draw the textures. I can have a large variety of textures to have many combinations:

  • Body textures. How does the body shape look? Does it have ridges, etc?
  • Markings. Does the body have any markings? Do they overlap? Perhaps some markings cover other markings too?
  • Marking Visibility. How visible are the markings? Are they transparent?
  • Marking colour. Do the markings have a different colour?
  • Head and tail.

For the body shapes, I would need 5 different sets of the same Body Texture. One for the head, one for the tail, one for the body moving normally, one for the body turning left, one for the body turning right. Then, I just combine them all.

Make Game asynchronous

To improve performance and make the game feel faster, I should make the game asynchronous. This helps as different functions are not going to be executed one after the other, such as drawing and movement.

The drawing and movement could be separated, allowing for the game to LOOK like it is moving faster

Analyse Simulation Data

As the simulation goes on, it should log data. Every 10 seconds, it will log different pieces of data so that it can show you different graphs about the data. Some stuff can be:

  • Total creature population over time
  • Species count over time (How many unique species there are)
  • Creature count within a species over time, layered atop each other. Perhaps bar charts.
  • Total food over time
  • Deaths over time
  • Etc.

The program will save this data in a database or in a json file. A database would be better as I can aggregate and group different things together. The database would be wiped each time a new simulation starts.

More data can be also tracked. Andreas can help me decide which data is important.
These graphs can help show trends and show how one thing can affect other things in an environment, such as one species growing in size, and killing off another species.

Framerate Independence

The game should run with framerate independence. Using deltatime correctly for each bodypart.

This could be done by having 2 values for x. The "actual value" which is a new variable to BodyPart and the "in-game" value, which would be the x and y of the rect.

The actual value is increased, and then rounded to the nearest whole number and set to the in-game value. This would be for collision detection.

However, when displaying it, the game would use the actual value, apply the transformations to it, and then round it. This would create a smoother viewing experience, while still keeping the actual coordinates as they are.

To account for speed, I would also need to change movement slightly by shifting all the bodyparts closer to the head. Or entirely change the movement mechanics

Track Creature Species

To detect when a new species is created, I need a reference creature. When the game starts, one creature from each species is chosen as that species' reference creature. Every child that is born within that species is then compared genetically to the reference creature. If it is different enough, then that creature is considered a new species and is then that new species' reference creature.

The checks will be as follows. If one or more checks is true, then it is considered a new species:

  • 50% of the genes have a +/- 0.5 or more difference in value
  • Any one of the RGB colour genes have a +/- 5 or more difference
  • One gene has a +/- 1 difference in value

The new species will receive a unique name pairing from a text document. The program has 2 lists and chooses one random name from each list, checks if another species has that name, if not, then all is well. So something like: Flubris Pulignus. Then, the first name of the parent species is added at the front: Terranus Flubris Pulignus.

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.