Claustrophobia and eggicide

Yesterday I put in claustrophobia for the snails. Jars have a capacity attribute - a maximum number of snails that they should hold. But just because a jar with a capacity of 20 may not be able to support 25 snails very well doesn’t mean the snails are going to conveniently stop reproducing or hatching (if it is a breeding jar). Instead, they’re just going to get uncomfortable enough to eat their babies.

It’s all kind of thrown together right now with arbitrary values, but first we get each snail’s claustrophobiaTrigger, which tells us how many other snails a snail has to have around it in order to start feeling claustrophobic. Right now this is the same for all snails, but eventually I can store it in the db and make it a more interesting attribute.

    protected function getClaustrophobiaTrigger() {
        return $this->jar->capacity / 4;
    }

{:lang=“php”}

comments powered by Disqus