Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

Auto Goobers - Evolution: Proof of concept devlog

A topic by JoelRencen created Jul 16, 2022 Views: 57
Viewing posts 1 to 1
(+1)

Hi all!

I’d like to prefix this by saying that this was my first ever game jam and the experience was brilliant! So many lovely people with so many great ideas that I’m already looking forward to more. I’ll also say that I only know Python as a programming language but learning it over the last 5 months or so has me very excited to learn more and maybe even different languages in the future too.

And finally before we begin, this will be very text heavy because I wasn’t thinking about documenting photos and videos as I went. And the current state of my project is very messy, so photos/videos to come shortly when things are running a little more smoothly!

As we’ve just entered the final 24 hours of the jam I figured it’s about time I posted some sort of progress. 

At this time Auto Goobers - Evolution is a proof of concept for an interactive evolution simulator/top down rts game I have plans for.
There will be options to influence the evolutionary path of a colony of Goobers by upgrading aspects of their genome. Such as by increasing their speed, changing their mutation rate and even the accuracy to which they can create and follow paths. This will be more inline with a rts game where you help control the narrative, however I’d also like the option for people to just run simulations of a colony or colonies. Changing starting parameters however they feel and watching how ‘Goobers’ evolve through the generations in response to selection pressures.

The game runs on the back of a genetic algorithm I wrote to simulate evolution through generations of ‘Goobers’. I’ll do my best to update this post at a later date and properly describe the algorithm using the code. For now though I’ll explain the basics; Goobers are my simulated species carrying out their little lives with double stranded DNA. These strands are split into sections, each of which encode a primary function of a Goober; Movement, Body Composition, Survivability, Interactivity and Energy Management. 

These primary functions are further segmented into codons, each with 64 combinations much like our own DNA. Every combination in a codon allows for the value/state of a Goobers function to be altered from its base. Unlike in our own DNA however, there is no need to split a Goobers DNA into a mRNA strand to produce their functions. Simply because the computer carries out their functions without needing to produce actual proteins! 

The only time a single strand is needed is when two Goobers breed. Here we carry out a fundamental procedure for all genetic algorithms and cross over sections of the two strands to create a brand new one. Throw in the chance for random spot mutations and voila, a new Goober inheriting aspects from both parents is born.

Creating a method to generate genomes has so far been the easiest part of my project, mostly because I much prefer backend coding and number crunching over asset and ui creation. Most of my time has been spent bashing my head against a wall getting these little guys to perform properly on screen, not just being numbers and letters on a terminal…

As I mentioned above, Python is the only coding language I know and I’m far from an expert in that. The Pygame library however seemed like a good choice for a proof of concept as I could spend minimal time on art and design whilst still having something on screen. Even if this is just circles , squares and primary colours! Of course Pygame doesn’t come equipped with as many tools as some game engines but I like the freedom it allows to build a framework from the ground up.

I have used Pygame a few times but only for text based projects, never for moving objects and certainly not at a scale of interactivity I have planned.  Re-familiarising myself with Pygame, setting up a screen, creating my Goober class and having them move about on screen all in random directions was the first task. This took about two days in of itself but many long loops later I was done and could watch my Goobers running around the screen happily.

My next task took much longer and was to create a camera system allowing me to pan across my screen and zoom in and out. I’ve not done anything like this before so had to watch and rewatch multiple tutorials on YouTube. Implementing this into my project and ironing out the kinks took about 4 days, it could have been much faster but frustration got the better of me and I could only handle so much at a time. Eventually I had a rudimentary box camera set up, an internal screen surface, scaled screen surface for zooming and had learned how to offset objects so that they’d stay in position whilst panning the ‘camera’.

I wasn’t thinking about writing a devlog at the time so didn’t take any pictures of the earlier stages of the project so you’ll have to just imagine my very basic screen full of circles.

Due to other commitments and some project burn out I didn’t do too much work the next 2 days aside from cleaning up a few loose ends, adding a collision method to test how Goobers could fight, spawning food circles that Goobers could pick up and adding a home point.

My next real goal and the one I am just on the edge of finishing was to implement a path finding/following system whereby Goobers learn to head home when they find food and to head back along the same path to go get more. This has turned out to be very tricky, involving some of the most convoluted loops I’ve ever written and even some secondary school level Pythagorean I swore I’d never need in real life. The principle here is for Goobers to drop a marker every X pixels whilst moving . Once a Goober has moved randomly into contact with a piece of food it then checks it’s immediate surrounding for any of these markers, checks the distance from its home point to each of those markers then stores the marker with the shortest distance in a ‘to home’ list. Random movement is then overtaken by a command to move to the markers coordinate. This process is repeated, moving the Goober back the way it came until it reaches its home point and can drop its food off. At this point, all other markers the Goober has dropped will be cleared, leaving only the ‘to home’ list. Now not carrying any food, the Goober can travel along the reverse of this list back to the food until the food source runs out, at which point the Goober will restart its random movement. 

This system is an important one I’d like to finish to a high degree of accuracy so that in the future it can be used to signal paths to enemy Goobers and other points of interest. Currently the problem I’m having is with multiple Goobers crossing paths and with Goobers forgetting markers they actually need. Hopefully another day or two of work will sort these issues out and I’ll then attempt to record a video of Goobers in action!!

So that brings development to today, where clearly Auto Goobers - Evolution isn’t complete however I’m very happy with all the progress I’ve made so far and with all that I’ve learnt. I fully intend to finish this project and maybe even take it beyond the proof of concept stage to a point where people can watch their own Goobers adapt and evolve over time vs a computer controlled colony or just simulate the effects of evolution in a population in response to various selection pressures.

My next steps are to integrate the breeding section of my algorithm into the game so that Goobers can actually evolve and to implement the Energy system whereby Goobers have to find food to move, breed and stay alive!

I’ll do my very best to update this where I can, although I’ll most likely make a separate post altogether outlining the details of the genetic algorithm as that will likely be long (longer than this) with awful diagrams and code snippets. Once the game is in a playable state I’ll upload a version on here for people to demo and give feed back on too!

If you’ve read this far then thank you for your time! I’ve thoroughly enjoyed this as my first game jam and can’t wait to participate in more in the future. It’s also been a pleasure reading so many great devlogs and I’m super excited to see what people have cooked up for me to enjoy!!