Turn-based decision making

This topic is 3656 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

Hello, i'm working on a turn-based hack 'n slash game. I'd like to implement some AI for my enemies. I'm new to this area of programming and don't know much about it. I want my enemies to make smart choices in combat. For example, if they have a healing potion, they will use it if running low on health. If they discover that player is immune to something, use something else etc. Anyone have experience writing something similar or can point me in the right direction? Maybe links to articles or papers? I did a search on the web, but came up with very little.

Share on other sites
Something like

if (health <= 20){    usePotion();}else{    Attack(player);}

Edit:
In the end it makes no difference if the AI is in an turn-based game or realtime game. They have to make these decisions in any game type.

Share on other sites
Ok, well... that's a start I guess. Although, I do want it to be a bit more complex than that. Say he doesn't have a potion, but a healing spell? or maybe the player is also low on health, so plant the final blow instead of healing self. Maybe my fire attacks are being absorbed by players armor, so switch to ice attack instead.

I guess some kind of list containing rules -> action, for the AI. Maybe it can rate each action and actually use the highest ranked one.

Share on other sites
There are a lot of systems that might work, but one that might be perfect for what you're looking for would be a blackboard system, where you keep track of the results of your attacks, such as fire being absorbed by armor. I would then rank each possible action, using the blackboard history as a factor.

So the desirability of a fire attack would decrease dramatically if you have "absorbed fire" in the blackboard, and the "use heal spell" would only become important after the character has suffered some amount of damage.

Share on other sites
This seems to be screaming out 'Fuzzy Logic' to me.

For example you could rate the need to use a potion to be

FuzzyValue GetShouldIUsePotion()
{
return min ( GetHealth(), GetMaxPossibleDamageFromOppsNextMove() );
}

each function in that method returning a fuzzy value between 0 - 1. You could have other methods to evaluate the possibility of performing other actions e.g.

FuzzyValue GetShouldIUseSomeKindOfAttack()
{
return min ( ..... );
}

After evaluating all possible actions, simply choose the one that returns the highest fuzzy value. Hope this is of help, fuzzy logic can be very simple but very powerful, its all about how you weight your functions.

[Edited by - makar on February 21, 2008 10:01:12 AM]

Share on other sites
Maybe you can describe the current state with a few numbers (own health, enemy's health, whatever else you want...) and have models of the effects of various actions on that state.

The models of the effects of actions can be smart enough to learn that in the current circumstances they are not behaving normally, and adapt to recent experiences (sounds hard).

You will also need a utility function (some measure of how happy the agent is with particular state, as a real number).

Then the procedure is to check each action, use your models to imagine what effects they are going to have, map the resulting state to a real number using the utility function and pick the action that maximizes that (well, the expected value of the utility, in case your models are probabilistic).

By improving the estimate of expected future utility and crafting the utility function carefully, you can get very smart behavior.

Share on other sites
A planner should work quite well in the turn-based case I think.