Inspiration

I thought a "Survival of the Fittest" concept could be interesting. I was surprised with how a couple of the scenarios turned out based on initial conditions so it was fun and something to play around with.

What it does

The project asks for user input regarding a specified amount of critters' max health and viewing distance as well as how much food should be provided. Then the critters are placed onto a 2D char array and search for food objects which will restore health within their view. If there is no food spotted, the critter will move in a random direction. The critter loses health each time it moves. Once all food has been depleted, time has run out, or every critter dies, a new generation of critters is spawned inheriting the traits of the 4 most viable critters, viable defined as 4 random surviving critters or the most recently starved if there are not enough surviving critters. There is a small amount of variance with each new generation. Once the user declines new critter generation a list of the average health and view distance for each generation is printed.

Challenges I ran into

Critter movement and char display. The critters would sometimes move in a completely unexpected direction when food was within the viewing distance or not move at all at times. One bug caused the object to move away from food when it was placed above or left of the object. The char array would stop updating due to how I changed char values with the object on movement.

What I learned

I learned a lot in regards to having different data structures communicate with each other. Halfway through I regretted a lot of the design choices I made and I was forced to create workarounds to deal with some of the issues in the project. This resulted in an undesirable amount of static variables. Creating another class to communicate between the char array as a controller would have streamlined a lot of the issues I was having and made the overall design of the project use less memory and run faster.

What's next for Critter survival

GUI Adding gameplay elements.

Built With

Share this project:

Updates