Even though I’ve had a functional breeding system in Gastropoda for a while, it still isn’t actually done. Most common snails do not give birth to live young…and definitely not to one live young. Initially it was good to just have the snails pop out one live baby snail so that I could properly observe and test the genetics and other attributes generated for the newborn. Now, however, with that being well on track, it is time to implement…egg laying.
The requirements were this:
- Quantity of eggs is based in part on the snail’s fertility attribute. Environmental and health factors will eventually come into effect.
- The snail now has to be pregnant for some time before actually laying the eggs. Eggs have to stay in the jar for some time before they hatch into baby snails.
- The baby snails are pregenerated at the time of the mating, not on egg hatching. This is because eventually environmental factors and the parents' health may have some effect here as well. I can easily modify additional attributes before hatching if needed, but the main attributes of the newborn snails must be set based on the state the parents were in when they actually mated.
- Snails can’t be born at their full size - they have to be born tiny and grow based on a maturity rate attribute.
At first I considered having a separate table for eggs, but then I decided not to complicate things. I added an
eggLaid attribute to the snail table. By default
eggLaid is set to false, so at the time of conception the snail-to-be exists but it doesn’t appear as an egg. The
birthDate is NULL at this time. In the jar we can see the eggs displayed on top of the pregnant snail’s shell like so:
(The number of circles on the shell doesn’t represent how many eggs will actually be laid. In the future I’ll make this much more subtle, the quantity will be indistinguishable).
A LayEggs event is created in the db. Currently it’s always scheduled for exactly an hour after mating. When this event runs
eggLaid is set to true in the snails table for those snails and they now appear as eggs (you can see an example of one of the eggs in the jar above). The color of the egg represents (to an extent) the shell color of the newborn, though without the pattern overlay it’s impossible to tell what the final snail will look like at this time. For me that’s pretty exciting, because I can come back in a few hours to start seeing what kind of shell pattern and eye color my baby snail is developing.
When the eggs are laid, a HatchEggs event is created. Eggs will hatch roughly 24 hours after they’re laid, but this will eventually have a tiny degree of randomization as well as be affected by factors like temperature and subtrate within the jar.
When the eggs are hatched, the snail is so tiny that you can barely see it. From there every hour the scale of the snail is increased based on the maturity rate attribute. Eventually the snail grows to its full size!
Up next I have to:
- Make sure that snails under 3 days of age do not count toward the jar capacity quota
- Make sure that snails can’t be picked for breeding until they’re fully mature
- Implement aggression - baby snails are vulnerable and can be eaten by other snails