Featured Blog | This community-written post highlights the best of what the game industry has to offer. Read more like it on the Game Developer Blogs.

Keeping little virtual people happy is no easy task! How do you track variables and compute their satisfaction? How do you calculate the final score? Here's my game design musings.

Jakub Kasztalski, Blogger

December 9, 2015

Things are getting messy...

My current side project is a silly, Theme Hospital inspired management sim where one takes over the creation and maintenance of restrooms in variety of settings, from small cafes and malls all the way to hospitals and even the Vatican. Dealing with needy customers, the dreadful after-lunch bathroom rush, dirty hobos and inspectors are just some of the challenges you will face on the path to epic poops!

The ultimate goal is ensuring the patrons have a quick and enjoyable time, whether they need to poop, wash themselves, change their baby's diaper, or puke after a long night of drinking. Their total satisfaction is used to compute the final score and monetary reward, so it's critical to lay out all the variables and math behind.

There are two key entities in the game:

• Structures (toilet, urinal, sink, dryer, radiator, painting, potplant, etc.)

• People (patrons, inspectors, specials, etc.)

The people have certain needs (poop, wash hands, etc) and the structures allow them to fulfill them. But there's more things to worry about!

## The Variables

Aside from simply checking if certain needs are fulfilled, there are a number of factors affecting a person's overall satisfaction:

• Patience - starting at 100%, the longer someone has to wait in line, the more their patience depletes. If it hits 0, the person will just angrily storm off.

• Dirtiness - as structures get used, their dirtiness increases. Using dirty structures increases a person's disgust and past a certain point, they will also angrily storm off.

• Heat - each person tracks their temperature calculated by their proximity to radiators. Too hot or too cold is no good!

• Luxury - global variable of how luxurious your establishment is. It can be increased by adding paintings, potplants, and other decor.

• Maybe more in the future as I expand the gameplay and add new structures and levels

On top of perpetually-increasing dirtiness, each structure can have a status such as "broken," "needs watering" (potplant) or "clogged." Alternate statuses trigger after x amount of uses and usually prevent further use of a structure or decrease their heat and luxury. They can be fixed by spending the hard earned cash.

## The Math: Single vs. Multiple meters

In computing the person's total satisfaction, I figured two potential approaches:

Single Meter: having a total Satisfaction variable that starts at 100% and slowly depletes if a person has to wait, the bathroom is beyond their dirtiness threshold, or they are too cold/hot.

• Math (per-frame): NewSatisfaction = CurrentSatisfaction - (IsWaiting ? 1 * dt : 0) - (IsTooDirty ? 1 * dt : 0) - (IsTooHotOrCold ? 1 * dt : 0)

Multiple Meters: having separate variables for patience (starts at 100% and depletes when waiting), disgust (starts at 0% and increases when using dirty structures) and comfort (starts at 100% and depletes when too hot/too cold).

• Math (at end): Satisfaction = (PatienceRating - DisgustRating + ComfortRating), with each rating decreasing per-frame.

The beauty of the first system is its simplicity: it's just one big variable to track and, more importantly, communicate to the player. Making the design so transparent would allow gamers to grasp the underlying mechanics much more quickly. If a patron is not having a good time for whatever reason, their satisfaction dwindles!

However, the second system allows for much greater control: I can clearly see how each variable decreases over time and balance it against each other and structure cost. It could also allow for additional effects, such as changing a person's icon to disgusted when their dirtiness is too high. But this means having 3x as many variables to communicate to the player.

## Thinking of the player

As I outlined above, a key consideration is the player experience. Looking at a bathroom with anywhere from 5-20 structures and equal number of patrons shuffling in an out, it quickly makes for A LOT of variables to keep track of!

Currently each person has a smiley icon above that changes experession with their overall satisfaction. A white ring around it slowly depletes, indicating their patience. Little fire/snowflake icons indicate being too hot/cold, and a fading-ing poop icon shows their current digust level. Similalry, structures will fade-in a poop icon with their dirtiness level, and occasional wrench icon will pop up if they need fixing.

Gauges were a TERRIBLE idea

This works well if everything boils down to one variable, but if I track patience, dirtiness, comfort (and maybe others?) separately, should I have a gauge for each? I tried that in an earlier prototype and it was overwhelming past 4-5 people. But perhaps there is no need to indicate that much detail, and a simple smiley face with side-icons is enough even if the underlying math is more complex?

For example, initially I had person stats that varied per person (i.e. some were more germophobic than others, some did not want to share bathrooms with opposite gender etc.) However, as the volume and pace of the game increased, I realized there was no time to micro-manage each person individually, especially when their stay in the bathroom is relatively brief. So instead I switched to making those variables global per-level, rather than each individual, and it's been working well.

## Other Questions

On top of the satisfaction calculations, there's a bunch of other design decisions on my mind:

• Incremental vs. boolean dirtiness - should it increase gradually for each structure, with cleanup cost being proportional to current state? Or be a simple clean/dirty like a status effect? The first allows for more varied gameplay, but the second is easier to grasp, especially in combination with numerous other systems.

• Environmental dirtiness - eventually I want to add people puking or throwing trash on the ground, which contributes to total dirtiness. But if person's disgust only increases by using dirty structures, how do you factor environmental dirt? Should it just be added to their disgust dynamically each time?

• Luxury - currently it affects the final rating you get when completing a level, rather than each person individually. Should a person's satisfaction be affected by it, however? It would make sense a bunch of nice paintings or a plant would improve the comfort, no? But how should it factor into the calculation?

• Balancing - with so many factors involved, it's a bit hard to grasp the sweet spot of challenging but fun. I should probably sit down and crunch some numbers based on the math outlined above to figure out a good baseline, and hope eventual testing helps to fine-tune it.

Intrigued by my work? Check out my website or my upcoming game below:

Comrade LISTEN! The Glorious Commonwealth's first Airship has been compromised! Who is the saboteur? Who can be saved? Uncover what the passengers are hiding and write the grisly conclusion of its final hours in an open-ended, player-driven adventure. Dziekujemy!