A Game of Snails - Breeding system
Over the past couple of weeks I’ve been attempting to get up at 5am to work on snails before going in to actual work. It’s been working for the most part apart from a couple of slip-ups and basically goes like this:
-
Alarm rings at 5, I peel one eye open
-
I turn off the alarm with an indistinguishable grumbling sound
-
I sleep for either 5 more minutes or 2 more hours…
When I do manage to get up before 5:30 or so I get quite a bit of snail work done. This morning I finished race creation as well as displaying currently active races on the client. Up next I’ll be opening race information and making a way to actually enter snails into a race. I’ve got the basic structure set up, but nothing is hooked up yet.
I figured I’d write a quick blog post about breeding, since someone asked me how it works. Breeding and racing are the two main parts of the game. Breeding is in a functional state, though I’m sure there will be many changes to it in the future. I’ve also included an actual real-game example of the kinds of offspring that are produced below.
You can’t talk about snail breeding without talking about the fact that some (most?) snails are hermaphrodites. I have always found this interesting and knew I wanted to work a less traditional method of using sexual orientation during breeding for this game. It’s also important to note that breeding, genders, etc in_ A Game of Snails_ do not accurately reflect real life - they are inspired by real life, but I took plenty of creative liberty with the entire babymaking process.
(I’m writing this in a hurry this morning and will proofread it tonight so you may see some minor errors)
Sexual orientation
Each snail has an orientation
attribute which can be an integer between -100
and 100
. Every starter or newborn snail starts out with an orientation of 0
. A positive orientation means the snail identifies more as a male and a negative orientation means the snail identifies more as a female. An orientation of 100
indicates that the snail identifies completely as male (and -100
as female).
Let’s say we have two snails named **Spot **and **Blot **(I’ve chosen androgynous names on purpose…) Spot and Blot are both adult starter snails with a sexual orientation of 0
. Now let’s say we want to breed Spot and Blot together, so we put them both in the breeding jar.
After a short matchmaking period, Spot and Blot decide they like each other and want to mate. This means one snail needs to take the male role of injecting its spear-like penis into the other snail, which takes on the female role. But Spot and Blot are both totally neutral in gender, so which is which? Well, it’s random…if both snails’ orientation is identical, the decision regarding which snail acts as a male and which acts as a female during the mating is completely randomized.
So let’s say Spot is randomly chosen to be the male and Blot is chosen to be the female. The orientation attribute now instantly changes for both snails as follows:
Spot.orientation = 100 Blot.orientation = -100
As soon as a snail is chosen to be male during a mating, its orientation gets kicked all the way up to 100
- the maximum male identifying value. As soon as a snail is chosen to be the female, its orientation does the same in the other direction, to -100
.
Spot and Blot mate and produce a newborn snail with a neutral orientation of 0
. They get removed from the breeding jar.
Now that they are back in their normal jar, their orientation slowly starts ticking back over toward 0
, at a rate of 1 step every 5 seconds (for example). This would mean that both Spot and Blot would be of totally neutral orientation again after 500 seconds/8.3 minutes.
However, let’s say Spot gets bred again only 5 minutes/300 seconds later, this time with a new snail named Knot. This means that Spot’s orientation is still at 60
. While not exactly the strongest male identifier, Spot still identifies as a male at this time. Let’s say Knot also identifies as a male with an orientation of 70
at the time of the mating. So which snail mates as a male and which as a female?
In this situation, Spot would be more likely to be chosen to take on the female role than Knot because Knot is feeling a little more masculine (with a higher male-identifying orientation value). Now that Spot has been chosen to mate as the female, its orientation goes all the way down to -100
and Knot’s goes all the way up to 100
.
Babymaking
There are two main timers that are used during the breeding process. The first is the breeding jar’s standard matchmaking timer (which right now I think is 10 seconds, with a slight degree of randomization). The timer gets reset each time a new snail is placed into the jar as long as there are at least two breedable snails in there. So let’s say we put in Spot, then Blot - the matchmaking timer starts. If no other snail is placed, Spot and Blot will be matched in 10 seconds. However, 5 seconds in we put in Knot and the whole thing restarts again. This gives us the opportunity to pick two random snail matings out of a group instead of mating as soon as we’ve put in just one pair. The snails can sniff each other out a little and see which way the cookie crumbles.
Once two snails are paired up the arousal timer starts. Each snail has an arousalTime
attribute. This is how long it takes the snail to actually be ready to mate after it’s paired. The snail with the highest arousal time is always the one that dictates how long we have to wait for the mating.
Once both snails are aroused, the mating takes place - both snails and the newborn (“foal”) are placed back into their main home jar. Eventually I may include a pregnancy timer, but for now babies are born instantly.
Genetics
But what actually happens during the birth of a snail?
All snails have traits that are passed on to their foals.
Visual traits
Visual traits are represented in the genes
attribute. We have genes.shellColor, genes.patternColor, genes.patternShape, genes.eyeColor
. Each gene has two alleles.
Eg snail.genes.shellColor.allele1
and snail.genes.shellColor.allele2
.
When two snails mate, we pick out the foal’s gene for shellColor
out of a virtual Punnett square of sorts.
Let’s say we have a stag and a doe with the following genes for shellColor
(uppercase being dominant and lower case recessive):
Stag shellColor allele1 = R shellColor allele2 = r
Doe shellColor allele1 = B shellColor allele2 = b
The various options that the foal would land with are:
R
r
B
RB
rB
b
Rb
rb
We randomly choose one of the four options above for the foal. In the case of an rb or RB matching the R is always dominant (I have three alleles for color in all - red, blue, green)
So for example if the baby snail ends up with rB for its shell color its shell will be of a blue shade, close to but not necessarily exactly the same as the shell color of the doe.
Here is an actual example of the breeding process and the offspring it has produced (if you’re confused about why the green snail shows up twice, for the purpose of this example I had to breed one of the snails with its offspring). I’ve placed gender markers to show which snail bred as the male and which as the female, but remember that in reality their orientation starts ticking back to neutral after the mating.
Hidden traits
Hidden traits like the core stats - speed, endurance, weight
, later aggression
- work a bit differently. Here I just take the average of the stag’s and doe’s attribute and randomize it a bit by offsetting by a certain percentage. Not the best way of doing it, but for now it works.
That’s the gist of breeding for now. There’s still work to do, but now I’m focusing more on racing as the breeding is at least mostly functional.