Jump to content
  • Advertisement
Sign in to follow this  
moeen k

questions about Utility AI

Recommended Posts

hi.

im reading about utility AI and seems its best new approach for programming NPCs.

there is not much resource about it. how it really works?

defining some actions, some scoring parameters. give score to those actions in any defined interval and choose best scorer as chosen action. that's all? is there any best approach for coding that in c# or Unity?

Share this post


Link to post
Share on other sites
Advertisement

Using that name is about 10 years old, but the model is much older.

The Sims is a good example of a game that uses it.  Every actor has a bunch of motives. You can see about 6 of them like hunger, bladder, energy, and social.  When the AI runs, it scans for a list of all the potential interactions. They range from things like "go to work", "play chess", "watch TV", "go to bed", "eat", "call a friend", and similar.  Each one looks at the motives and sees how well they can satisfy it, generating a score. When you're not hungry, eating won't satisfy any motives so it gets a very low score. When you are hungry, eating gets a much higher score. When you are dying of starvation food gets an incredibly high score.  Taking a shower is normally a very low score, unless your hygine is bad.  But taking a shower also has a tremendously high score when you catch fire, since it will put the fire out.  All the motives can have their utility score tabulated very rapidly, and the top items are considered by the AI for the next action.

More complex utilities can be developed in different games.  In city building games, the utility of each building can have many different scores.  It may have a score because of the direct effect, and it may have more score because of side effects.  Sum them all together than that's the total utility.  The choices with the highest utility should then be considered using additional criteria, such as the availability of resources.

As an approach, there are basically two: ask the object for a score, or ask how they change motives. In the first you can query the object giving it the list of your needs and than asking a score as a result. It can be a single function that takes a collection and returns a float. Or you can reverse it, asking every object what satisfaction it provides and it returns a collection, then use the resulting collection of motives to compute the score yourself.  Which is better depends on your game's plans, if and how you intent do expand your game in the future, the design of your game, what you use for utility functions, and much more.

 

Share this post


Link to post
Share on other sites
29 minutes ago, IADaveMark said:

Sorry... my fault.

Wait. I thought you were responsible for the name "utility-based salad". :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!