Sign in to follow this  
AhmedCoeia

Awareness AI

Recommended Posts

Hi,

Suppose I'm creating a racing game.. I would like to implement an awareness system AI, that needs to suggest to the player that he can buy that booster, buy that stuff,..etc. 

How should I start implementing that? A FSM ? A decision tree ?

Suppose that I have variables like, how many crashes, how much is the damage, how many gates I have passed,..etc how would I use those variables then?

Share this post


Link to post
Share on other sites

Where exactly do you want to show this information? You could display the suggestions during the race, in the loading screen, in the pause menu, in a specific upgrades screen, etc.

 

This is one way you could do it. I'll use Python for this example.

money = 800
inventoryList = []
bodyworkCost = 300
booster9000Cost = 500
booster9000 = 'Booster stats/data replaces this string'
gatesPassed = 2

# If you've crashed more than once and your damage is high, suggest body work.

if ( money >= bodyworkCost ):
    if ( carCrashes > 1 ) and ( carDamage > 60 ):
        print( 'Your car has been severely damaged! You can purchase body work for $300.' )

# If you've passed 3 gates and have enough money for the booster, suggest the booster.

if ( money >= booster9000Cost ) and ( ( booster9000 in inventoryList ) == False ):
    if gatesPassed == 3:
        print( 'Congratulations! A new booster is now available! Would you like to purchase this upgrade?' )

You're essentially checking for specific conditions, and then displaying the appropriate messages.

 

I hope this helps,

 

On Rye

Edited by On Rye

Share this post


Link to post
Share on other sites

Thanks all. My question was it can be modeled as a FSM or more complex like Decision tree ? 

 

How about point based system ? How would I design that or how would you model it ?  like for example to raise the body work suggestion, you should have scored 50 points of crashes ?

 

The point is I would like also to measure how fit is the player depends on the number of  crashes, gates passed,..etc then I want to show him a suggestion.. 

Edited by AhmedCoeia

Share this post


Link to post
Share on other sites
My point is that you're trying to pick a tool but you don't even know what you're going to use the tool for.

Design the game feature first. Write down the rules for when suggestions appear. Then think about how to implement what you want.


It does nobody any good to pick out a really shiny, sharp tool - say, a chainsaw - and then discover that what you really need is a wrench.

Share this post


Link to post
Share on other sites

To make ApochPiQ's point of view even more clear, I'll exercise one possible route of thoughts (the one I've gone during working out an answer before reading ApochPiQ's posts):

 

When reading the OP and interpreting the statement made there, I see "suggesting the player that he can buy that item". What are the conditions for this? The player can buy an item if a) the item is for sale, and b) the item is offered, and c) the item's price can be payed. Now, that has not really something to do with variables like number of crashes and damage state and, err, how many gates have been passed (whatever that should mean in this context). Considering such variables means in fact not what can be bought but what is meaningful to be bought.

 

Well, with meaningfulness you have another condition to fulfill: It is an advantage to buy a specific item, be it as an addition or as an replacement (the latter comes into play to give damage another dimension). In reality it is even more complicated: It is more meaningful to buy item A and B, or else item C, because your budget allows just for the one or other decision?

 

So you are in the realm of optimization: What combination of all offered items give me the best with respect to a goal (winning a race), under consideration of restrictions (e.g. the budget). That is what you want to solve!

 

After working that out ... is a FSM good for this optimization? A big No! Is a decision tree good for this optimization? Also No! To be precise, both can be used, but you have to model all possible states explicitly. That would be okay if only a few items exist and variables are also very restrictive in count and possible states. But in general it ranges between far too much work and impossible to do. However, since this is an optimization problem, it can be assumed that optimization strategies exist which are able to solve it...

Edited by haegarr

Share this post


Link to post
Share on other sites

Google is your friend.

To be fair, mathematical optimisation is a giant rabbit hole down which you may never emerge, if not approached with a clear idea of what you are looking to achieve. Along with the other tools mentioned so far (decision trees, FSM), I would argue that it is entirely overkill for the problem the OP has described.

Racing games tend to have a very small pool of upgrade types. If you bucket upgrades by the effect they have, you end up with acceleration, top speed, and handling, with durability and afterburner in less realistic scenarios. With such a limited pool, it's pretty easy to manually write the conditions where upgrades are beneficial.

Does the player keep crashing? They should upgrade handling. Does the player keep finishing outside the top 3? They should upgrade top speed. Does the player keep being overtaken? They should upgrade acceleration...

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