Help Patchman rescue the Sheeple from enslavement by the Drone army!

Post feature Report RSS Coding the Sheeple: AI in a Realtime Physics World

Their brains are composed of a "problem -> solution(s) -> plan(s)" system.

Posted by on


Designing and programming the Sheeple AI was very challenging. I realize it's not the most complex artificial intelligence ever made, but it was hard enough. It's mostly state machines controlled by fuzzy desires, plan lists, pathfinding (no waypoints), memories, timers, and various stats.

It's harder to do AI when you're in a realtime physics world, where all sorts of things can happen at any time. By contrast a turn-based tile-bound system doesn't have the same concerns. One of the toughest things for me was just having the sheeple wait. Wait between actions, pause, to look like they're contemplating... instead of just doing everything immediately whenever they want to. It's also hard to explain why this was hard.

Their brains are composed of a "problem -> solution(s) -> plan(s)" system. They have one overarching goal (problem) that is picked from a priority-sorted list of problems, then N solutions are calculated to complete that goal, and each solution can have M plans (actions) to do. Each plan is a concrete action, like traveling to point X, or opening a fridge. Each solution is a group of related plans, like "open fridge, check fridge", or "find path, wait, travel". Solutions and plans are stored in a list with an index that increases each time a plan or solution is successfully completed. When the plan index counter reaches the total number of plans, the next solution is enacted. When the solution index counter reaches the total number of solutions, then the problem is completed successfully. This has the benefit of multiple problems/solutions reusing the same plan logic, such as traveling. There is a "plan_failed" flag that can force a problem recalculation at any step, such as if they get stuck traveling. Problem resolution is also convoluted and is done at the start of each AI step. To cut down on CPU, only one top-level AI is run per frame (problems/solutions) but the atomized plans (traveling, etc) are run every frame.

[VIDEO - Sheeple Development]

We all go a little crazy coding sometimes...

One failure on my part was avoidance AI. Sure, they don't get stuck, and they do go around each other. But they do so in a very unnatural way, using strong repellent vectors. For the longest time they would encircle each other endlessly until I added a dot-product facing-plane test that checks if their directions are in conflict or not. The AI is fairly robust though, fast, doesn't crash or leak memory. The Sheeple will find the nearest repeater, fridge, and vending machine on their own, and if there isn't one, they will react accordingly. They don't die of starvation, but they still get hungry standing in front of that repeater. But what is that white stuff getting sucked out of them? And where is it going?

We've shown two major components of our game mechanics: Plants and Sheeple. And of these components, roughly half of their available features. We still have a third major component to reveal. We hope to reveal the third component next week, and following that, reveal how all their features fit together in our trailer!

[RESULT - Sheeple Brochure]

In case you missed it last time...

PS. Great time for a hard drive crash! I test-rendered these videos shortly before my hard disk got corrupted beyond hope. It isn't finished, I was going to redo the narration and tweak it, but this will have to do. Gotta move on...

Post a comment
Sign in or join with:

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.

Follow Report Profile
Patchman vs. Blue Squares
Windows, Mac, Linux, iOS, Android
Send Message
Release date
Game watch
Related Games
Related Engines
Moai MIT