Skip to main content
GameDev.net gamedev.net
🔒 Locked

A decision-making model for running a colony simulation.

Started by Denn_im Jun 22 at 9:09 PM 8 replies 750+ views
Original Post
Denn_im
Denn_im

Hey, I'm working on a colony sim game, and right now I'm thinking about how to build the decision making system. So far I've settled on a setup where in the config file you tweak the weights of the character's stats, and those affect the overall weight of each decision. It seems to be working okay so far, but I'm wondering, are there any other approaches out there?


LorenzoGatti
LorenzoGatti

Naming doesn't seem very standard:

  • What your panel calls "weights" seem to be the scores of possible behaviours (characters prefer the behaviour with the highest score), which can be obtained by multiplying constant weights and variable measures that represent behaviour usefulness (for example character gluttony * a suitable fixed nonlinear function of the number of game turns since their last meal = current desire to eat).

  • What your panel calls "stats" are actually transient and highly volatile state variables: traditionally, character stats are understood as much more permanent and constant numeric values (for example D&D describes characters with the six stats of Strength, Constitution, Dexterity, Intelligence, Wisdom and Charisma, which traditionally change with magic item bonuses, terrible permanent damage, and few other rare circumstances). Both types of quantity can be useful inputs of behaviour selection, but for a coherent character model the distinction is important.

If selecting the highest score behaviour every turn yields stupid characters, you'll probably need a planning system or corrections like persisting with the same action until it accomplishes a result (e.g. after beginning combat target the same enemy each turn until disabled, surrendered or retreated).

Omae Wa Mou Shindeiru
Alan Voren (PlayServ)
Alan Voren (PlayServ)

Utility AI is what you've basically reinvented, and it's the standard for colony sims - The Sims, RimWorld, and Dwarf Fortress all variations of the same idea. Worth looking up Dave Mark's talks on it; he's the person most engineers credit for codifying it. The next step beyond simple weights is curve-based scoring - hunger at 30% shouldn't be 3x more important than at 10%, it should follow a curve. That's where decisions stop feeling linear.

None
Denn_im
Denn_im

Thanks for the answers! I'm glad I'm moving in the right direction, I was thinking about a mini neural network, but I guess debugging that would be very difficult.

Alan Voren (PlayServ) wrote:

Utility AI is what you've basically reinvented, and it's the standard for colony sims - The Sims, RimWorld, and Dwarf Fortress all variations of the same idea. Worth looking up Dave Mark's talks on it; he's the person most engineers credit for codifying it. The next step beyond simple weights is curve-based scoring - hunger at 30% shouldn't be 3x more important than at 10%, it should follow a curve. That's where decisions stop feeling linear.

Thanks for the pointer, I'll check it out. As for the curves yeah, I've already run into the need to prioritize some desires over others. I'm also thinking I need to introduce negative values that would turn things off or lower weights, also following a curve.

Denn_im
Denn_im

LorenzoGatti wrote:

Naming doesn't seem very standard:

What your panel calls "weights" seem to be the scores of possible behaviours (characters prefer the behaviour with the highest score), which can be obtained by multiplying constant weights and variable measures that represent behaviour usefulness (for example character gluttony * a suitable fixed nonlinear function of the number of game turns since their last meal = current desire to eat).

What your panel calls "stats" are actually transient and highly volati...


For planning, I'm thinking of adding something like short-term and long-term memory. For example, if something interrupts an action, it should return to the last one, and also store goals (where to go, what to do). Sounds simple enough so far, haha.

LorenzoGatti
LorenzoGatti

Denn_im wrote:

For planning, I'm thinking of adding something like short-term and long-term memory. For example, if something interrupts an action, it should return to the last one, and also store goals (where to go, what to do). Sounds simple enough so far, haha.

Planning is reasoning, not only memory. For example, suppose the character becomes hungry while exploring a cave without food supplies. They now want to eat, and they know that they cannot eat if they don't have food. So they should plan hierarchically, in most cases figuring out that they have to exit the cave as a preliminary subgoal, according to a database of what they can do:

  • they can get food by preparing one of several known recipes with certain ingredients and required tools

  • they can get food by obtaining ready food


  • for each recipe, they can prepare it by getting all needed ingredients and tools (some could already be in the character's inventory) and then following steps that are actions by themselves (e.g. knife+dead rabbit -> rabbit meat; then pot+water+vegetables+a suitable fire -> rabbit stew; then rabbit stew+knife+fork->successful meal)

  • for each environment, foraging or hunting can yield some ingredients or directly edible food

  • for each known grocery store, restaurant, etc. there are various ingredients and food types that can be bought there

  • for each known house, pottery store, hardware store etc. there are cooking tools that are available for use or can be bought

Many goals require movement, or satisfying prerequisites

Denn_im wrote:

For planning, I'm thinking of adding something like short-term and long-term memory. For example, if something interrupts an action, it should return to the last one, and also store goals (where to go, what to do). Sounds simple enough so far, haha.

Typical planning operates with a stack of current goals and activities in progress, not vague memory and interruptions. For example, if a character wants to eat they can choose an immediate plan like eating some food from their inventory, or they can require long and complex hierarchies of subgoals:

  • order an omelet at the restaurant -> go to the restaurant -> cross the river -> build a bridge -> cut two medium trees or three small ones-> find the first tree->...

Omae Wa Mou Shindeiru
ecpm_insights
ecpm_insights

I’d keep the system as debuggable as possible before trying anything like a neural network.

A weighted utility system is useful because you can inspect why a character picked one action over another. For example, logging the top 3 possible actions and their scores each turn would probably help a lot.

Two things I’d consider adding:

  • a bit of inertia, so characters do not switch tasks too often

  • a clear separation between immediate needs and longer-term goals

That way the behavior can still feel flexible, but you can understand and tune it when something looks wrong.

rumbleavenue
rumbleavenue

In my opinion with AI these days that would be a logical choice to tap into some form of AI Agent that you build. However that of course adds a whole new layer to the game and additional dependency on a third party piece of software. With that aside, I would suggest doing more than just 'weights' as those are one time values. I would certainly consider environmental factors in the game (weather, terrain, etc). And in doing so you can build a series of heuristics that the game can then follow (no different than how those old time computer chess games used to operate). In my own experience with the game I created, I needed bots to be the player's opponent, so I sorta built these intelligence layers, and they seem to do ok without relying on AI.


ecpm_insights
ecpm_insights

I agree with that. Environmental factors are probably where the system starts to feel less mechanical without needing a full AI-agent layer.

For a colony sim, I’d probably treat weather, terrain, distance, danger, hunger, and social context as modifiers on top of the base utility score. The important part is that each modifier should still be visible enough to debug.

If a colonist chooses a strange action, the designer should be able to inspect something like: base need + terrain cost + weather penalty + nearby threat + task priority. That makes the behavior feel smarter while still being tunable.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.