Programming cats

Have you ever wondered how many cats you would have if you started with just one female and left it alone with males for 5 years?

No? Nor had I… Until this morning!

I connected to the IdleMonkeys IRC server and was greeted by the following statement from Zach:

Did you know that 1 female cat not spayed will produce in 5 years, through her offspring and their offspring and their offspring etc. etc. 700,000!

I thought this sounded high, and so Zach and I did a few pointless calculations before I got the idea to write a script that would simulate this whole thing. I started out by writing a module to represent a cat. I called it Cat.pm and it looks like this:

package Cat;
use strict;
use base qw(Class::Accessor::Fast);
Cat->mk_accessors(qw(gender age pregnant pregnant_days gestation_period days_since_litter sexual_maturity));

1;

Very simply it defines a few values like the age and gender of a cat. Thanks to Class:Accessor::Fast I can easily get and set these values in my main script using something like this:

my $cat = Cat->new({ gender => 'Male', age => 0''});

Or

$cat->gender('Female');
$cat->age(12); #Age in days

I did a bunch of “research” (thanks Wikipedia) on the reproductive habits of the common house cat and found the ranges to configure for the gestation period, age of sexual maturity, etc. etc. It turns out that a female cat can be sexually mature at 5 months old, and can give birth around 2 months later. Cats tend to mate for 9 months of the year, skipping winter. After giving birth to around 3-5 kittens most cats have a period of at least around a month where they don’t get pregnant again, although it could be a lot longer. Zach asked me to specify that 60% of the cats born in a litter be female. I have no figures to suggest this is accurate, but I went with it anyway.

I programmed the first version of my script before I knew all of those facts and arrived at a number of around 5 million cats after 5 years of breeding. This was obviously ridiculous, and so I revised my script a few times.

With all the information I gathered I came up with a much lower figure than either of the previous ones. Over 10 runs of the script the average number of cats after 5 years was 16492.4. I ran the script through 1000 complete iterations and generated an average for all runs. The script took 3 hours 38 minutes and 15 seconds to execute and calculated an average of 10400.693 cats. 🙂

There are a few problems with this script:

  • The first major problem is that there is no notion of males breeding with any females that are not descendants of the first cat. If other non-related females were around then the number would be significantly higher, as the males would be able to mate with all of them, and would produce a huge increase in numbers. So, this whole thing assumes that there is only one female cat in the entire world when the script starts running.
  • The script assumes that the first cat is born right at the beginning of the breeding season. If that changes then the figures would probably be quite different.
  • The script assumes that a cat will become pregnant exactly 30 days after giving birth to the previous litter (assuming it is within the breeding season).

Obviously there are many other shortcomings, but there will always be some when simulating any sort of behaviour like this.

8 thoughts on “Programming cats

  1. Pingback: Tweets that mention Programming cats | Stu.ie – A boy named Stu -- Topsy.com

  2. Very nifty walk through of your fact checking process. Sometimes we forget when presented with facts such as the one above that; the methods to arrive at those conclusions can be completely inaccurate(to the point that it mind of well just been made up).

    A couple things I noticed you didn’t consider which may have a significant affect on your results (or at least the ones that bug me):

    1) Random cat death. In nature some kittens just don’t make it to breeding maturity.
    2) Limiting the simulations ability to support the cats. In the real world, breading is not only dictated by the season or how many female cats there are, but also by many other external factors such as food supply, predators, and the general nature of cats to be curious and kill themselves.

    But like you noted: “there will always be some when simulating any sort of behaviour like this.”

  3. i had a feemale cat once…the boy cats sure loved her. she had little ones every freakin month it felt like. boy, she got around the block.

  4. I’m sure I’m not the only one who is genuinely interested in seeing this performed as a real live experiment (possibly run several times in parallel to average the numbers).

  5. Pingback: Been Looking For a New Pet… – Zachary Fouts - Random Rambling Randomness

  6. Thanks Stu, I wrote a bit more about it (and copied your article) over here .

    namely where I found the snippet that I pasted, and why I found it.

  7. Andrew-I for one work at an animal shelter and have seen the effects of cats breeding in the suburbs. The litters range from 2-9 kittens. Unweaned kittens cannot be raised in a shelter and are euthanized. It’s a horrible situation. DON’T FEED STRAYS!

Leave a Reply

Your email address will not be published. Required fields are marked *