Jump to content

Breeding Rabbits - It maybe a stupid project. But it's MY stupid project.

Earl Dadanur

The story with this little project starts in the Fall of 2019. I was bored during a Intro into Java class. And was sitting in the front row. Wasn't going to try to play games. But I figured I could tinker around with P5.js. I had also watch this video during the summer and figured I'd try to make my own. And while It isn't as polished as Sebastian Lague's but I plan on continuing to improve it. I've also been using it to practice using git and GitHub as well. If your interested in seeing the current public version here's the link: [Link Removed] It being a personal project I wasn't going to pay someone to host it. But this place will host it for free. Just takes forever to download. If you want to my explaination of what's going on I'll be putting in a spoiler. Just in case someone else want's to try this idea on their own.

 

Example of late simulation

Spoiler

image.thumb.png.3ac365d37a004436e9ea6f7e755e3189.png

 

Example of chart that generates at the end of a run.

Spoiler

image.thumb.png.4ce033a2f1831267fe4f855c0ba066d1.png

 

Upper left is frame rate with each cyan line representing 10 fps.

Upper right is the population of each generation as well as the total population over the course of it.

Lower left is a chart of the genetic variation of the population. Showing both the average of the population as well as the highest values found. The traits being tracked being the following.

  • Red - Range of sight
  • Blue - Speed
  • Green - Rate of growth
  • Navy(Overlapping green here) - Value that affects how long they are "pregnant" for.

Lower right is not used at the moment.

 

Explanation

Spoiler

The idea is simple. Rabbits are their own class. With 4 main variables.

  1. rate
    • Affects how soon after getting pregnant they give birth. Also affects how many are born at a time. As well as how hungry and thirsty the babies are at birth. Higher values lead to larger and faster litters that can die faster of starvation if they don't find food soon after birth.
  2. growRate
    • Affects how fast rabbits grow from being babies to being mature and able to breed.
  3. sight
    • Affects how close something has to be for them to react to it.
  4. speed
    • Affects movement speed both in travel and turning. But also affects how fast they get hungry or thirsty inversely.

These 4 values then affect how the rabbits survive and act. And when rabbits breed the values from the parents are averaged with a random value also added to simulate mutations that can occur.

 

After this, it is simply scaled up. The plants actually have similar values in them as well. But this has yet to really be used because of problems.

 

Each rabbit also has a time to live value that counts down. At the moment this isn't affected by any of the other values but that may change. If you want to see the code it is easily accessible using chromes inspect tool. Just find the sketch.js file and you'll find the main source.

I may post small updates when I update the public code. Feel free to ask questions. Also I know this code is shit. I plan on refactoring it so that it's more readable and less cluttered. But the fact that I haven't really sat down and looked through everything at once doesn't help.

Edited by Earl Dadanur
Removed link as I plan on taking the page it references down.
Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×