Evolution Explanation:

The purpose of this simulation is to show that Evolution helps/promotes survival.

How the simulation works:

Firstly, the user can input the number of pacmans and their approximate starting size (their diameter in pixels) at the start. Once the simulation begins, the pacmans will always lose health, and to gain health, they need to eat food. Dots of food randomly spawn every few seconds around the screen. A pacman must collide with a food dot to consume it. If a pacman doesn't eat food, it will visually fade away and will disappear from the screen (die) once its health reaches 0. Secondly, a pacman's direction of movement is totally random and changes every few seconds, but its speed is constant based on its size. The number of pixels a pacman travels per second based on its diameter x is given by the function: \[S(x)=\frac{50}{x}\] \[20\leq x\leq100\] This means that larger sized pacmans move slower, while smaller pacmans move faster. Lastly, pacmans can reproduce. There are no genders when it comes to reproduction, but a pacman must reach two requirements to have the ability to reproduce. The first step to reproduction is to reach maturity. A pacman matures after 14-19 seconds of living. The second step to reproduction is to be healthy. If a pacman is close to dying/is visually starting to fade away, it will not be able to reproduce. This means that a pacman must eat good amounts of food to be able to reproduce. Once a pacman has the ability to reproduce, it will turn orange, but if it doesn't eat enough food, it can become unhealthy and therefore lose its ability to reproduce. If two orange pacmans collide with one another, 9 times out of 10, a non-mutant child with a size averaged from its two parents will be born. 1 time out of 10, a mutant child with a size slightly different than the average size of its two parents will be born.

If a pacman's size differs from the average size of its parents, it would be a mutation, and this is where survival of the fittest comes into play. Certain sizes can have much higher advantages when it comes to eating food and reproduction, and thanks to mutation, the perfect size could be born which would then dominate the pacman world.

Where's the Evolution?

It all comes down to what size pacman is able to reproduce and pass their genes on the most. Is speedy and small better for reproduction, or big and slow? One might think a medium sized pacman is the best size because it's the perfect balance between speed and size. It covers a decent area making it more likely to come in contact with food, and its speed makes it more likely to collide with other pacmans resulting in more of its genes are passed down than any other size pacman. Well, this is exactly what the goal of this simulation is to see. What size pacman will dominate after 1 minute? 10 minutes? An hour? A day? What's even more interesting is that screen size also plays a role in this as well. The size (in pixels) of the screen plays a huge roll because the physical boundaries of the pacmans change. If theres more pixels, there is more room for the pacmans to move. Below the simulation, there are two charts recording live data from the simulation, one of them which graphs time versus the pacman population and average pacman size. 2 instances of this simulation, one on an iPhone and one on a 4K display were ran overnight, and each showed different results as to what size was best for the pacmans to thrive and survive. The blue line is the average pacman diameter (in pixels), while the red line is the pacman population:

4K Display:

iPhone:

Hmm... Interesting... It seems so that a larger diameter is more useful for lower resolution screens while smaller diameter is more useful for higher resolution screens. Leave the simulation up for at least 10 hours to see some good results. If you switch tabs or go to another application, the simulation will not run, so it is recommended to leave this on a device overnight or at a time where it is not used. See the ideal pacman size for your screen!