CaddieOpen in CaddieDownload for Mac

The Genius AI Behind The Sims

Shared by Caddie Library · Updated
Game Maker's Toolkit21:38Open on YouTube
Chapters show their main points

The bottom line

The Sims runs on utility AI: Sims, places and whole towns carry needs, and each picks the option that best meets them. Because the same simple idea scales from one person to a neighbourhood and leaves room for ambiguity, it yields believable characters and leaves the stories to the player.

Key takeaways

  • Objects advertise what they offer, and each Sim scores those offers against its own needs. 2:34
    • A bed says "sleep on me to get 10 energy", and a toilet offers plus 20 to bladder.
    • A well-rested Sim damps the bed's score, and an exhausted Sim boosts it dramatically.
  • Tuning makes the scores feel human instead of robotic. 4:35
    • Each motive has its own curve, so starving outranks boredom, and personality and distance also change the score.
    • The Sim picks at random among the top-scoring options, so it never meets its needs perfectly.
  • Traits are extra motives, so the same system makes every Sim unique. 8:57
    • Five trait slots and about 60 traits give roughly 5 million possible Sims in The Sims 3.
    • Temporary motives like "be in gym" make Sims act fittingly in social places, and hand-written rules cover cases like visits and jokes.
  • Towns and lots have motives too, and background Sims are only simulated at low detail. 13:31
    • The town aims for a 50/50 gender balance and about 80% employment, and checks itself at midnight.
    • When a background Sim becomes a foreground Sim, its motives snap to a chart for the time of day.
  • The Sims holds back on simulation so players can tell their own stories. 17:31
    • The urinal rule was cut because predictable behaviour was dull and random choice made funnier moments.
    • Simlish keeps meaning ambiguous, and autonomy never goes against the story the player is telling.

So the final piece of this AI puzzle is knowing when to hold back. Knowing what NOT to simulate.

Mark Brown

Chapter summaries

0:00 Intro

Sims need free will so players don't have to micromanage them, but it can't be so smart that play stops.

  • Autonomy has to meet three demands at once. 0:26
    • Sims must read as believable humans and adapt to any house or social situation.
    • They can't be so smart the player can sit back and do nothing.
    • Micromanaging a whole family's needs gets tedious, which pushed Maxis to add autonomy.
    • The focus is the original game and The Sims 3.

1:26 Decision Making 101

Objects advertise, and the Sim weighs the offers by need
The same advertised +10 energy counts for little to a rested Sim and for a lot to an exhausted one.

A Sim's choices come from needs that constantly decay and from objects that say how to refill them.

  • Eight motives drain over time and add up to a Sim's happiness. 1:26
    • In The Sims 1 they are hunger, hygiene, fun, energy, bladder, social, comfort and room, each from -100 to +100.
    • Without a command, the Sim lists every object in the house, weights their offers and takes the top one.
    • Each motive decays at its own rate, tuned to roughly eight hours of sleep and three meals a day.
    • Bladder drains faster while the Sim is eating.
    • Will Wright took the idea from SimAnt, where ants follow pheromones and Sims follow fridges and TVs.

3:43 Advanced Decision Making

Survival needs shout when low, and fun keeps calling
Physical needsHigher needs
ExamplesHunger, bladder, hygiene, energyFun, social, comfort
Pull is strongestWhen the meter is lowAs the Sim gets happier
Can be satisfied?Yes, peeing fills bladderNever too much fun
Maslow levelBase of pyramidHigher up
Starving and boredEats the sandwichNetflix waits
Following Maslow's hierarchy, basic needs outrank fun when they are urgent, while fun is never fully satisfied.

Raw scores make Sims robotic, so tweaks and overrides make their choices feel human.

  • The curves follow Maslow's hierarchy of needs. 4:41
    • Physical needs like hunger, bladder, hygiene and energy matter most when they are low.
    • Fun, social and comfort grow more attractive as the Sim gets happier.
    • Peeing satisfies the bladder, but you can never have too much fun.
    • A pinball machine and a bookcase advertise the same fun, but a serious Sim reads.
  • Some interactions override or lock out the rest. 5:59
    • A phone call or a school bus overrides every other score.
    • Some objects don't advertise to kids, adults or visiting guests.
    • Randomness means Sims can't meet every need, which gives the player something to do.
    • Nearby objects score higher because distance counts.

6:52 Utility AI

Putting the data on objects makes the system easy to grow.

  • Utility AI lets a Sim in any house act lifelike without new code. 7:25
    • Sims tend to hunger and energy when needed, and socialise or have fun when not.
    • Maxis can add hundreds of objects and endless expansion packs without touching the rest of the code.
    • It is also called needs-based AI, and the option with the most utility wins.
    • All four games in the franchise use it.

7:51 Unique Sims

In The Sims 3, traits shape both what Sims do and what they want.

  • Traits change behaviour beyond decisions. 8:28
    • A clumsy Sim trips while walking, and a slob farts and burps while idle.
    • Acting on a trait earns bonus moodlets.
    • Some interactions are exclusive, like a computer whizz making cash by hacking.
    • The traits swapped in for the Sims 1 personality meters, which were neatness and playfulness.
  • Objects advertise to trait motives the way fridges advertise to hunger. 9:07
    • A couch potato needs the sofa and TV as much as it needs to pee.
    • Scaring a Sim, stealing candy from a child and smashing a dollhouse are advertised to evil Sims.
    • Writing a trolling comment on the computer is advertised to them too.

9:50 Social Situations

Temporary motives make Sims behave properly in any setting, and traits can override them.

  • Context motives are added and removed as the situation changes. 10:11
    • A host is motivated to be hospitable while guests are around, and guests to act acceptably.
    • In The Sims Medieval, work motives apply only while a Sim is on the clock.
    • This replaces hand-scripting a bunch of specific rules and interactions.
  • A trait can override the social norm. 10:33
    • At a picnic, friends and family are drawn to join and strangers are discouraged.
    • An "inappropriate" Sim sits with strangers to make them uncomfortable.
    • So most Sims act believably while a few stand out.

11:09 Hard-coded Rules

The most specific matching rule decides the Sim's response
Because only one ranked rule ever fires, Maxis could pile on thousands of rules without them breaking each other.

Where autonomous motives fall short, hand-written production rules cover specific social cases.

  • House visits are policed by a ruleset of social norms. 11:15
    • A guest who sleeps in the host's bed or uses their computer gets a warning from the host.
    • If the guest goes further, the host kicks them out.
    • The rules exist because guests may stay too long, or the player may make them act badly.
  • Conversations run on input, conditions and output rules, and the most specific rule wins. 12:06
    • A joke gets a laugh from a listener with a good sense of humour, an insult if the relationship is sour, and boredom if it is repeated.
    • Maxis wrote thousands of rules for hundreds of conversation topics.
    • Rules sit in a stack ranked by specificity, so they can't clash or loop forever.
    • Designers can keep adding rules to the pile.

13:00 Background Sims

Towns and lots run on the same motive idea, and off-screen Sims are only faked at low detail.

  • Lots pull in Sims by lending them temporary motives. 14:07
    • A restaurant wanting about 8 diners outside at meal times gives Sims the "eat outside" motive.
    • It favours Sims with traits like culinary and discourages frugal ones.
    • The town runs on the same logic as the Sims themselves.
  • Background Sims are only scored once a day for big life changes. 14:51
    • The system scores getting a job, falling in love or marrying, weighted by traits, relationships and careers.
    • Neighbours may look like they live full lives off camera, but they don't.
    • Designers made charts of likely needs through the day, such as low hunger just after lunch.

15:35 Storytelling

Players supply the stories, so the game stays vague enough to leave room for them.

  • Players built elaborate stories around their Sim families. 16:08
    • Will Wright was surprised in playtests: It was fascinating to me how readily people would build a story around this.
    • Maxis added a last-minute comic maker with screenshots and captions, and it was very popular.
  • Ambiguity gives players room to imagine. 17:41
    • Simlish came from two improv comics after Maxis tried English, Navajo, Estonian and Ukrainian.
    • EA's Matt Brown: If we used actual language, the game would flatten and shrink.
    • Ambiguity also hides moments where the simulation goes wrong.
  • Autonomy follows the player's lead and never negates it. 18:53
    • Sims relieve themselves and eat on their own, but won't quit a job or romance a random Sim.
    • The principle is "yes, and" from improv comedy.
    • A male Sim told to flirt with other men is treated as bi or gay.

19:51 Conclusion

Utility AI reaches well beyond life sims.

  • Other games use the same scoring idea. 20:36
    • An XCOM enemy scores every tile it can reach and moves to the best one.
    • The scoring uses distance, flanking, angle, cover bonus, visibility and proximity.
    • It can also drive procedural generation of worlds that meet set requirements.

In the growth library

Mark Brown, creator of Game Maker's Toolkit. Explains how The Sims builds believable autonomous characters with needs-based utility AI, from single Sims to whole neighborhoods, and why it deliberately holds back to leave room for player stories. The example worth watching is the cut urinal rule, which shows that a less realistic simulation can make a better game.

More from Game Maker's Toolkit · The whole library, and ask it anything

Transcript301 lines
Intro 0:00
0:00

The Sims is a digital dollhouse, filled with little computer people. And it's your job to keep them alive, keep them happy, and keep their house furnished with ever more expensive trinkets. But micromanaging the needs and desires of an entire family can get pretty tedious. So the developers at Maxis soon realised that they'd need to give these guys a certain amount of autonomy. Free will. The power to think for themselves, if the player stops giving direct commands.

0:31

Which is actually... a pretty complicated task! These characters need to read as believable humans. And they need to be able to adapt to any possible house you build around them, or any social situation they find themselves in. And - crucially - they can't be so smart that the player can just sit back and do nothing. So how do you make a video game AI that can do all of that? Well, that's what I want to explore in this video.

0:59

I'm going to break down the clever ways that Maxis designed autonomy in this four-game franchise - though with a focus on the original game, and - let's be honest - the best one, which is The Sims 3. It's not going to get too technical, but there is a metric buttload of resources in the description if you want to dive deeper. With that out of the way, I'm Mark Brown, this is Game Maker's Toolkit, and here's how The Sims... think.

Decision Making 101 1:26
1:26

Okay - decision making in The Sims is all driven by a set of mental and physical needs - dubbed "motives", by Maxis. In The Sims 1 that's hunger, hygiene, fun, energy, bladder, social, comfort, and room, or tidiness. They all go from negative 100 to positive 100, and if you combine them all, you get the Sim's overall level of happiness. These meters are constantly ticking down - each decaying at slightly different rates, and faster if the Sim is performing a related action.

2:00

The bladder meter drops more quickly when the Sim is eating, for instance. Maxis carefully tuned all of these rates to hopefully match a normal human schedule - like needing eight hours of sleep, and three meals a day. So. If the player doesn't give the Sim a command, it will decide what to do by itself - and that decision is driven by a desire to fulfil these motives. Now you might assume that a Sim knows how to meet its own needs: that a toilet will solve bladder, that fridges and stoves solve hunger, and books, TVs, and pinball tables solve fun.

2:32

But it doesn't work like that - it's actually, the other way around. Instead, all of the objects in the Sim's house contain this data, and will broadcast what they can offer. A bed will say "sleep on me to get 10 energy", a toilet offers plus 20 to bladder if you use it, or plus 5 to room if you clean it. And other Sims will offer themselves as a way to top up social points. Maxis calls these "advertisements". So. Whenever the Sim decides what to do, it quickly makes a list of every object in the house - and what they can offer.

3:07

The Sim can then take that advertised number and weigh it based on its current needs. It does this by applying a multiplier to the promised score, based on the Sim's current motive levels. For example, if the Sim is well-rested, the bed's energy-boosting score is damped down - but if the Sim is knackered, then that same score is boosted dramatically. Now, the Sim can take the list of interactions, and their weighted scores, and rank them.

3:34

At the top of the list is the interaction that will give the most benefit to the Sim right now... and so the digital dude should do just that.

Advanced Decision Making 3:43
3:43

This clever system was actually inspired by one of designer Will Wright's previous games: SimAnt - a virtual ant colony where the critters would be tempted to move by attractive pheromones. It's basically the same idea - but instead of pheromones, its TVs, fridges, pinball machines, and bath tubs. However - people aren't ants. And so if this was implemented exactly as I just described, it would lead to weird behaviours that make Sims seem either robotic or irrational.

4:14

So, many careful tweaks are needed to make it work properly. For instance, not all needs are equal. If a Sim is both starving to death and utterly bored, they should probably eat a sandwich rather than binge Netflix. But if the fridge and TV are both offering the same reward... which should The Sim pick? Well, more rational behaviour can be achieved by defining unique curves for each motive. For hunger, we want a curve like this: now, the fridge's score will be reduced to almost zero when the Sim is full, but will be extremely high when the Sim is starving - making that more important than any other motive.

4:57

Similar, smaller curves are used for the other physiological needs like bladder, hygiene, and energy. However, less important needs like fun, social, and comfort actually increase as the Sim becomes more happy. This was inspired by Maslow's hierarchy of needs, which says humans will focus on cognitive and social tasks only when their more basic lizard-brain needs are met. Plus - while peeing will satiate your bladder, you can never have too much fun.

5:29

We can also weigh the scores based on other factors, too. For instance, each Sim has its own personality - based on their score in areas like niceness, neatness, and playfulness. So while a pinball machine and a bookcase might advertise the same boost to fun, a Sim will weigh this based on their level of playfulness. Therefore, a more serious Sim will choose to pick up a book. Plus, we can weigh the interaction based on its distance from the Sim - which will make nearby objects more tempting.

5:59

Finally, some interactions can override everything - like a telephone call or a school bus. And other interactions can be locked entirely - so, certain objects won't advertise themselves to kids, or adults, or a visiting guest. All of these factors combined give us a much more useful score, which has been adjusted to the different needs, personality, and proximity of the Sim. And it's from these scores that the Sim's next move is picked.

6:27

But - perhaps most importantly of all - the Sim doesn't actually choose the best option every time. Instead - the Sim picks one of the top scoring interactions... at random. This stops the Sims from feeling robotic and overly predictable, and it also means they're not able to fulfil all their needs perfectly. Which, you know, actually gives the player something to do.

Utility AI 6:52
6:52

What I've just described is a special type of AI called utility AI, or needs-based AI. This is a system where a character has a predefined set of needs, then looks around at its current options, and picks the one that will fulfil its needs best - the one with the most utility. And in The Sims, it means a little person can be dropped into any house and will then act in a lifelike manner: carefully attending to its hunger and energy when necessary, but socialising and having fun when not.

7:25

Plus, by putting the information on the objects, instead of the Sim, it's really easy for Maxis to add hundreds of objects to the game - or make endless expansion packs - without touching the rest of the code. And so for these reasons, this basic system has been used in all four games in the franchise. But, Maxis wanted to take things even further when making the ambitious third game in the series.

Unique Sims 7:51
7:51

Okay, so, in The Sims 1, we saw how each Sim's personality - like their neatness and playfulness - would impact their decision making. This would make each Sim feel somewhat distinct. But for The Sims 3 this idea was expanded dramatically by swapping the personality meters with traits. Things like neat, neurotic, heavy sleeper, and commitment issues. With five trait slots, and 60-odd traits in the base game alone, that's about 5 million possible Sims - effectively making every character unique.

8:28

Now these traits have many impacts on the Sim - like, how a clumsy Sim will trip themselves up while walking, and a slob will fart and burp while idle. Sims also get bonus moodlets for acting to their traits - and there are certain interactions that are exclusive to Sims with certain traits: like how a computer whizz can make cash through hacking. But these traits also impact on the Sim's decision making. This time, however, instead of weighing the scores against the Sim's personality, the Sims 3 actually just adds more motives to the pile.

9:02

So, in the code, every Sim has their usual basic needs, like hunger, energy, and bladder - but also five more motives related to their traits. Therefore a couch potato needs to sit on the sofa and watch TV, just like how they need to pee, eat, and sleep. And then, in the same way that a fridge advertises itself as a fix for hunger, objects can advertise themselves as a fix for the Sim's trait-related motives. For instance, interactions like scare a Sim, steal candy from a child, smash a dollhouse, and write a trolling comment on the computer are all advertised to Sims with the evil trait.

9:42

This means that Sims are encouraged to enact their unique personalities autonomously - while also juggling their standard, everyday needs.

Social Situations 9:50
9:51

Now this idea - of adding additional motives to a Sim - can also be used to simulate social situations. For instance, if a Sim enters a gym they will temporarily be given the additional motive "be in gym" - which is satisfied by objects like a workout bench or treadmill. When they leave, the motive is removed. Back at home, a Sim will be motivated to act as a hospitable host for as long as they have guests around - meanwhile, the guests will be motivated to act in an way that's socially acceptable.

10:22

And in The Sims Medieval, a Sim is given work-related motives while they're on the clock, and then loses them during breaks. However: these motives can also be affected by traits. For example, if a Sim sits down to have a picnic, then the Sim's friends and family are motivated to join them - while strangers are discouraged. But a Sim with the "inappropriate" trait will override this - and they will in fact be motivated to sit with people they don't know.

10:47

Just to make them feel uncomfortable. All of this means that Sims will act naturally and believably in whatever location they end up in - but with a few Sims standing out as acting unusually, because of their unique personality. And this is all done by simply tweaking the Sim's motivations - rather than hand-scripting a bunch of specific rules and interactions.

Hard-coded Rules 11:09
11:09

Though, that being said, sometimes you do need more hard-coded rules. Take that house visit I mentioned. A visiting sim is indeed motivated to act in an appropriate way. But what happens if they stay for too long? Or if the player steps in and makes the Sim act inappropriately? Well, to make this work, the house visit is overseen by a set of rules that dictate social norms. So if a Sim sleeps in the host's bed or uses their computer, the ruleset will instruct the host to warn the Sim, and then kick them out if they go even further.

11:45

Likewise, conversations need more hands-on authoring to reflect extremely specific pair-ups of people, or super distinct social cues. For example, how should a Sim respond to a joke if they are steaming mad at the joke teller? Or if the other Sim has said the same joke 5 times in a row? This is done through a series of rules - with an input, a set of conditions, and the output. So for that joke I just mentioned... if the listener has the 'good sense of humour' trait, they'll laugh.

12:19

If their long-term relationship is sour, they'll be insulted. And if the Sim repeatedly tells jokes, the listener will be bored. These so-called "production rules" are ranked in order of specificity, as defined by the designer, and the top-scoring outcome is used to pick the response. Maxis ended up writing 1000s of hand-crafted rules to determine the outcome of 100s of possible conversation topics. But, because the rules just go in a big stack and the most specific one is picked, they can't clash, break the game, cause an infinite loop, or lead to any other issue.

12:53

Just like with the objects, designers can simply keep adding more and more to the pile. So far, I've been talking about individual Sims,

Background Sims 13:00
13:03

or small social situations like a conversation or a party. But what about simulating an entire town's worth of little people? You see, in The Sims 3, your house exists in an open world neighbourhood with dozens of other Sims, and features homes, restaurants, a park, and so on. Maxis needed to invent new tools to make all of this work - but, in truth, the neighbourhood actually operates in a similar way to the Sims themselves.

13:31

That's because the town also has a bunch of motives, and will make choices that will help it fulfil its needs. For instance - it ideally wants to maintain a 50/50 gender balance. So when a new Sim is added to the neighbourhood, the probability of it being male or female is weighted by the current needs of the city. It also has a desired employment rate of about 80% - so it can force background Sims to get hired or fired as seen fit.

13:59

Basically - once a day, at midnight, the town will check its own happiness level, and take a few actions in order to satisfy its needs. The individual lots have motives too - for instance, the restaurant may wish to have roughly 8 people eating outside, during lunch and dinner hours. To achieve this, the lot will temporarily give the "eat outside" motive to a bunch of Sims to tempt them to the restaurant. It can even narrow the focus to Sims with certain traits - like culinary - and discourage those with other traits - like frugal.

14:32

Now, these Sims that appear at the restaurant seem like fully autonomous characters. They have needs, they have families, they may even have had a baby and changed job since you last saw them. So are they are actually living out their own little simulated lives, just off camera? Well, not quite. The background Sims are actually simulated at a very low level of detail. Each day, the system looks at each Sim, and scores possible big life changes that could happen to them - like getting a job, falling in love with someone, or getting married.

15:04

These are, of course, weighted using things like traits, existing relationships, and career paths. Also, the designers created charts for what a Sim's needs will likely look like throughout the day. If it's just after lunch, for instance, they're probably not going to be very hungry. And so when a background Sim is promoted into being a foreground Sim, because they're in proximity to the player, the system checks the time of day and snaps all their motives to the chart.

15:33

Clever stuff.

Storytelling 15:35
15:35

So we've got tools to simulate characters, conversations, house visits, restaurants and entire towns. And when you have such clever tech, it's tempting to simulate, well, everything. Take, for instance, the urinal rule. If you pee while standing up, you know the deal: when picking a place to take a leak, you should always try to maintain a one urinal buffer from other people. It's like an unwritten social rule. So Maxis added this rule to the game, as well...

16:05

but, before the game launched, they took it out. That's because when the Sim followed that rule it was just kind of predictable and dull. But if Sims picked toilets at random, it would often lead to funny and memorable moments of Sims acting awkwardly. You see, while The Sims might have started life as a rather nerdy simulation game - essentially SimCity, but at a much smaller scale - it quickly grew into something very different.

16:32

In playtests for the original game, Will Wright was surprised that players would tell elaborate stories about their Sim families - embellishing details, reading into their decisions, and playing up random moments. "It was fascinating to me how readily people would build a story around this," Wright says. To support this, Maxis added a last-minute feature to the game: the ability to take a screenshot, write a caption, and create a simple comic book which could be uploaded to EA's website with a click.

17:02

The feature was extremely popular, proving that for many people... The Sims was an avenue for storytelling. And that's still true today - just search YouTube for The Sims to see what I mean. But supporting storytelling is a delicate balance: the game needs to be specific enough to create stories, but not so specific that there's no room for the player's imagination. So the final piece of this AI puzzle... is knowing when to hold back.

17:33

Knowing what NOT to simulate. Knowing when to make urinal choice random, rather than scripted. One way to do this is to carefully employ ambiguity. Basically, to leave some things unsaid, so players can make assumptions, and project their own head-canon on the events on screen. A good example of this is the Sim's iconic babbling dialect, known as Simlish. In early design documents we can see that Maxis experimented with having the Sims speak real world languages like English, Navajo, Estonian, and Ukranian - but due to technical and logistical reasons, they ended up hiring two improv comics to just make up absolute nonsense.

18:17

Sim: Droba droba droba. Seeka neeba huh. But this actually works wonders - when the Sims babble gobbledygook at each other, the player can assume, fill in gaps, project their own imagination on the Sims, and make the game their own. "If we used actual language, the game would flatten and shrink, and everyone would be having the same experience", says EA's Matt Brown - no relation. Ambiguity can also make Sims feels smarter than they actually are, and hide cases where the simulation is doing something wrong.

18:53

Another avenue is to always follow the player's lead - and never use autonomy to go against the story the player is trying to tell. That's why Sims will use free will to relieve their bladder and fill their stomach, but won't autonomously quit their job or try romancing a random Sim. Just like with the Nemesis System in Shadow of War, Maxis took inspiration from the concept "yes, and", from improvisational comedy - so the Sims try to build on the player's actions, and try not to negate them.

19:26

For instance, if a player makes two Sims fall in love - the autonomous system shouldn't make them break up again. Likewise, user-created Sims enter the world with no sexual preference. But if you instruct a male Sim to, say, flirt with other dudes, you're suggesting that he should be bi or gay and the game will run with that. The game should always try to maintain the consistency of the player's story.

Conclusion 19:51
19:51

So, The Sims has a fascinating AI system - which allows for realistic human simulations, and creative player-led storytelling. And most of it is driven by a very simple concept. Characters, locations, and entire neighbourhoods are given a bunch of needs - and then try to make choices that will best fulfil those needs. With a little clever tuning, this leads to characters who feel believable, social situations where Sims act appropriately, and entire neighbourhoods that stay consistent and balanced.

20:26

But this is not just useful for running quirky goal-free life simulations - and we can see utility AI being used in other types of games, too. For instance, in XCOM, an enemy unit will consider every tile it can move to and score them based on factors like distance, flanking opportunities, angle, cover bonus, visibility, and proximity - before moving to the tile with the best score. It can also be used in procedural generation, to build worlds that fit predetermined requirements.

21:00

Utility AI is a fantastic addition to a game maker's toolkit, and its implementation in The Sims should serve as wonderful inspiration to game designers. And now, just to melt your brain, here's Katy Perry singing in Simlish. Katy Perry: [Absolute nonsense] Katy Perry: [Just complete gobbledegook] Katy Perry: [I think I'm having a stroke]