most realistic sheep simulator in existence

learning Nov 22, 2021

Computer scientists are very smart. They are able to solve complex problems to achieve their goals and make successful products. They wield tools that are baffling to the average person but still manage to design simple interfaces that the rest of us can understand.

Sheep can do none of those things. I've spent the better part of almost two decades herding sheep, and let me tell you the one thing I've learned from all of it: sheep are not smart.

I don't know if it's nostalgia or just curiosity, but I've kept my eye out for a good sheep herding simulator and have yet to find one. Every one I've looked at fails to understand one key bit of information: sheep are very dumb.

When a computer scientist sets out to program a sheep, they usually start with the fact that sheep like to be close to each other. When you program that, it gives you something like this:

But this isn't how sheep actually behave. If they acted like this, they would smother each other. The next thing a programmer might do is tell the sheep not to get too close to each other:

That doesn't look right either.

Instead of doing these things, I've changed the rules here beginning with the fact that sheep don't really make decisions. They just exist in a semi-conscious state of reacting to the world around them.

First things first, sheep basically move randomly when there's no other simulation. Here's what that looks like:

They just wander around aimlessly, bumping into each other and everything else. I can confirm that this is accurate behavior.

Now, to continue the randomness, instead of setting hard and fast rules for how sheep make decisions, I'm going to say that a sheep will randomly choose between two options:

  1. Move toward another random individual sheep.
  2. Move away from another random individual sheep.

This is called a stochastic simulation. It is a much more accurate representation of how sheep actually behave and it has the bonus of being less computationally intensive (just like a sheep's brain). Here's what it looks like when I incorporate that one simple rule:

And here's what they look like after a long time of running the simulation:

Now that's all fine and good, but will they herd? Yes! Yes, they will!

My simulation assumes two things that relate to herding:

  1. A sheep is very unlikely to actually see and react to the shepherd.
  2. A sheep is very likely to do whatever it sees another sheep doing.

In practice, this means that when there's a shepherd trying to herd the sheep, only a few of the sheep see the shepherd and run away; however, a lot of sheep see the other sheep running and choose to do the same thing:

Here's a video of my sheep simulator in action! I've decided to call it Sheep Sim and release it as a playable game.

You can play the simulator right here:

And for those who like to code, here's the Github link:

GitHub - t8rn8r/sheep_sim: The most realistic sheep simulator in existence
The most realistic sheep simulator in existence. Contribute to t8rn8r/sheep_sim development by creating an account on GitHub.

subscribe to get email updates and support my work

Click the link below or the subscribe button at the bottom of the page to support my work and get an email every time I make a new post!

A website. Helps you keep up with Tate!


Great! You've successfully subscribed.
Great! Next, complete checkout for full access.
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.