[Updated] DecisionFlex: AI toolkit for emergent and human-like decision making

http://www.tenpn.com/DecisionFlex.html

Have you ever found yourself writing cascading if-else statements to evaluate what your AI does next? Constantly tweaking logic and parameters to make the AI behave realistically, only to find an edge case that makes your grunt try to snipe a distant foe instead of the enemy trying to knife him?

Enter DecisionFlex, a toolkit for adding emergent and human-like decision making to your Unity game.

It’s useful for:

  • A soldier choosing its next target, based on target range, type and the soldier’s ammo count
  • A Sims-like human choosing to eat, drink, work or exercise based on hunger, thirst, wealth and fitness
  • A bot choosing to prioritise picking up a health pack, based on the bot’s HP and distance to the nearest pack
  • Any time you find AI trying to make a decision between many actions based on multiple factors

You simply use editor-based tools you already know, like the hierarchy and animation curves, to define a decision as a series of actions. Each action then has one or more considerations, such as enemy range, ammo count and weapon strength, informing DecisionFlex how to weigh that action against others. And that’s it! Iterate, tweak and extend easily, until you have fantastic AI.

You can find more info on DecisionFlex, including several web demos, and buy direct at http://www.tenpn.com/DecisionFlex.html. You can buy it on the asset store at DecisionFlex | Behavior AI | Unity Asset Store.

Ask questions below!

An early-access version of DecisionFlex is available to buy now: DecisionFlex by tenpn

It’s feature-complete but the documentation is still in progress. Anyone buying now will get a full version from itch on release.

The documentation and tutorial are complete! The plan is to finish some mobile optimisations, then submit to the asset store. DecisionFlex: DecisionFlex v0.9

…DecisionFlex is submitted to the asset store! Until it goes live, you can still buy it for 20% off at http://www.tenpn.com/DecisionFlex.html.

Hi could this also be used for relationship/faction AI as well?

Certainly! Without knowing your specifics, each faction would want several reasons (in DecisionFlex-speak, “considerations”) of why they would like the player. Eg, number of missions completed for the faction, and time since last completed mission. You could then let DecisionFlex decide that even though someone’s played a lot of missions for faction A, they have played /some/ missions more recently for faction B, so A doesn’t like them too much any more. All arranged very visually in the editor, with no cascading hard-to-maintain if-else blocks in your scripts.

So if I get it at your website would it be possible to get a unity voucher when it goes live so I can update it via the asset store? After providing proof of purchase, of course.

I’m sorry, I’d really like to, but there’s two reasons why I can’t convert a purchase on my site into an asset store code:

  • unity only lets me make 12 vouchers per package per year, so I couldn’t give it to all customers who had already bought through my site, let alone new purchases
  • unity’s T&Cs expressly say I can’t “sell vouchers or otherwise charge for them”

However anyone who buys through my site will be able to download new versions any time there’s an update. I’ll be figuring out some way to keep people informed of updates as well - I have the email of customers, but don’t necessarily want to spam them. I’ll definitely be updating this thread.

Could you use this to create personalities?

Hey Licarell, I’ll need some more info on your specific game to answer that. DecisionFlex is for choosing between multiple actions, so while you could and should implement personalities into your decisions, DecisionFlex is more like one manifestation of your AI’s personality than a complete solution itself.

For an example, let’s pretend we’re working on a support character that will play alongside the player. We could use DecisionFlex to choose the next target to attack, and the weapon to use - attack nearby players first, use sniper rifle against far targets, use knife if you’re out of ammo, etc. A very aggressive support character could have a boost to his knife action, making melee combat more likely. Or a sniper support character could have a preference for sniping targets even if near, and running rather than resorting to a knife for near-by enemies. All of this would be set up with animation curves in the editor, and would be easy to iterate on at runtime.

Ok, no problem. I went along and purchased the package. The demos look really good.

Well my thoughts are that you could have a follower that through spending time, quests, would build like an affection level… that a follower could fall in love, be jealous, upset if the player does something wrong, (needless killing, stealing etc.) kinda like Skyrim in the fact that they allowed marriage.

Ah now I understand a bit better. That’s certainly possible, using DecisionFlex as one part of that system. DF is very focused on single decisions, and doesn’t do state, so you’d need some tracker of current affection, and events and actions changing that affection over time. However when it comes to decide if the follower should for example marry the player now, then DecisionFlex would step in and make the decision based on the affection level, and maybe personality traits and other factors.

DecisionFlex is very much an AI tool rather than a framework, and I think that’s reflected in the $45 price. It’s something you might find yourself using in many different places in your game in many different contexts.

DecisionFlex is released! Check it out on the Asset Store at DecisionFlex | Behavior AI | Unity Asset Store, or buy it direct at http://www.tenpn.com/DecisionFlex.html.

1 Like

Been thinking about this. Could a social meter be added to the human ai that would make agents want to talk to other agents.

Hey Andrew a question, can Decision Flex be suitable for fighting game AI? Because the only thing on the Asset Store at the moment that can be used for fighting games is Fuzzy AI but it’s only for a game toolkit called UFE. I’m very interested in Decision Flex and would like to know what kind of games can it be used best for if not a fighting game. I look forward to hearing from you Andrew. Cheers!

Hey Blue, I think I need more info to answer your question properly. DecisionFlex could be used to decide if an NPC was going to talk to you, or if an NPC should choose “talk” out of many possible actions. But it is most suited to situations where there are many factors (“considerations” in DFlex-speak) informing each choice. If the social meter was combined with say, time since last talked and distance to other NPCs, DecisionFlex would work very well indeed.

By itself, I think DecisionFlex would work ok for fighting game AI. You might want to combine it with a simple state machine or behaviour tree as well for added flexibility.

Let’s break down an example and see how it could work! DecisionFlex is a tool for deciding between one of many actions, based on multiple considerations. In our case those actions could be block, punch high, kick low, etc. DecisionFlex asks each action for a score, and makes a selection based on those scores. Some games might want to always pick the highest-scoring action, while others might want to pick randomly but biased towards the high-scoring actions. This latter approach makes things seem a bit more human at the cost of an ocassional mistake, so let’s use it for our fighting game.

Considerations are parented to individual actions. The action scores itself by asking each consideration for an individual score, and multiplying them all together. Punch High might have a NearOpponent consideration that scores high when the opponent is near and StandingOpponent that scores high when the opponent is standing. So if you’re standing near an opponent, punching gets a really good score and therefore a good chance of executing. As you move away, the score drops until beyond some distance it reaches zero.

Block might have a AttackingOpponent consideration that scores highly when the opponent is attacking and another NearOpponent similar to before. It could also have an AggressiveStyle consideration that scores low when the AI character is an aggressive one. Since consideration scores are multiplied together for the action score, a low AggressiveStyle consideration will make blocking less likely, letting other actions happen more.

This post is getting a bit epic, but let’s look at some examples:

              Ex1     Ex2   
Punch       
- NearOpp      0.8    0.8   
- StandingOpp  0      1     
             = 0      0.8   
Block
- NearOpp      0.8    0.8   
- AttackingOpp 0.7    0.9   
- Aggressive   0.5    0.5   
             = 0.28   0.36

In the first example, the player isn’t standing, so the punch action knows it doesn’t want to execute. Block is allowed because an attack is happening. In the second example, the player is standing and attacking. Block’s Aggressive consideration brings the score right down, so punch is much more likely to execute than block.

You can find these kind of decisions - between multiple actions, based on multiple considerations - in almost every game, and DecisionFlex can help you make those decisions more human and interesting to the player.

Hi there! DecisionFlex is now at version 1.1. This new release includes a new BooleanConsideration for using bools in your AI, and official certified unity 5 support.

Get it on the asset store DecisionFlex | Behavior AI | Unity Asset Store or direct from me http://www.tenpn.com/DecisionFlex.html

2 Likes

@andrew-fray

Hello! I’m interested in using DF for my game AI, and I have some questions. I confess to being a newcomer into utility based AI, so for all of them, a general question would be “does it depends on DF or my game code?” :slight_smile:

Multiple Simultaneous Actions
Is it possible to arrive to more than one simultaneous decision?
Example: the character is under attack, so the desired result would be that it has to shoot, and also move towards cover because it has low health.

Is it feasible or I have to make three actions? (shoot / move / shoot and move) That would seem to defeat the purpose, though.

Re-utilizing considerations
Can agents share a consideration made by another? Mostly to avoid calculating several times the same or similar thing.
Example: having one soldier in a group detecting an enemy which evaluates to be close enough and a big threat level, make the rest of the soldiers of the group use that same threat value (instead of individually calculating distances again) as input for their individual decision making.

Multiple utilities
I’m thinking about an example in the book “Behavioral mathematics for game AI”, which you probably have read :slight_smile:
Specifically (figure 9.1 for reference) where it shows that it factors multiple utilities to arrive to a single value, and then evaluate that value with another (which also was calculated from multiple utilities), and only then arriving at a decision.
Basically, N levels of considerations before choosing an action.

Is that’s possible to do with DF? I imagine using a hierarchy of considerations, where the input is the result from the previous considerations.

Example: The one I can think right now it’s related to the previous question, where I’d want to take one of the utility results from the first level to be re-utilized for another action, without having to be recalculated for everybody, but not from the second and third levels.

Replacement for GOAP
You mentioned that DF can be used together with other systems (as a matter of fact, my original idea when I started researching Utility Based AI, was to use DF to decide the WHAT to do, and my current GOAP implementation for the HOW to do it), but I’m wondering how applicable would be DF to replace GOAP by making those decisions on the fly.

Cheers!