protocolpav / simbiosis Goto Github PK
View Code? Open in Web Editor NEWMy Computer Science A-Level NEA Project in Python
My Computer Science A-Level NEA Project in Python
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:
Food should be allowed to be configured in the config file.
These are the options:
Perhaps I can add so that creatures can sometimes "pick up" food and drop it on collision, and that is how new clusters spawn.
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:
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:
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.
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
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.
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.
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:
Have a config file where the user can change it and configure the environment.
This would include stuff like:
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.
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.
Instead of making separate IDs for food and creatures, make IDs for the BaseEntity class, which would remove any confusion
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
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.
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
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?
Right now, there are three characteristics that can change the way a creature looks:
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:
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.
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
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:
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.
self explanatory
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
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:
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.