Reaction AI v2.0 implementation info

You can see a melee example implementation in this video:

The implementation basic sample for this is attached.

to create the brain, you simply need to instatiate a brain object like so:
Brain brain = new Brain(30000, “SampleJSONPersonalityInputFile”);

here, 30000 is the number of neurons for this brain. If you have multiple NPCs, each NPC will need it’s own brain object.

I’ve also attached a sample personality input file. This file has all the “reactions” the AI can perform and you would need to map that to an animation and NPCs action and implement your own logic for that (can be anything you want such as IDLE, BLOCK, FLEE, ATTACK_MELEE, ATTACK_SHOOT, etc). This file is specified for how you want the AI to be able to do and can be different for different NPCs that use Reaction AI.

Here are all the API calls after instatiating the “brain”:

reaction = brain.sendStimuli(avAction);//Reaction AI API #1, avAction is the action the avatar just performed

npcAction = reaction.getAction();//Reaction AI API #2
reaction.getSubReaction();//Reaction AI API #3
reaction.getEmotion();//Reaction AI API #4
reaction.getVisualRank();//Reaction AI API #5
reaction.getSpeed();//Reaction AI API #6
brain.createNewMemory(reaction, successPercent);//successPercent can be a formula based on how much damage the NPC has inflicted on the avatar and how much damage the avatar has inflicted on the NPC - example
brain.clearStimuli();//required to create new memories

It should not affect framerate as the computation speed is high. Just an FYI, a brain with an extremely large of neurons will take longer processing times.

2960066–219706–ReactionAISampleImplementation.cs (20.3 KB)
2960069–219709–SampleJSONPersonalityInputFile.txt (1015 Bytes)
2960066–219707–ReactionAIDemo.pdf (637 KB)

Also wanted to add…a successful block by the AI is deemed success as well. For example, if the AI blocks with 0 damage, this could have a successPercent of 100 or any other value you choose to balance

If you still close the source, i think it too difficult to custom AI.

There is still customization you can do with the personality initialization and the successPercent you set for each mapped reaction.

@CoderPro

I have submitted a source code release for review…will update here if it gets approved.

1 Like

Interested in getting this. How exactly does this scale with multiple npcs? Or is it more suited to 1-1 interaction? Either one is fine.

@ikazrima

It will work for for either. For multiple NPCs, each one will need its own “brain” object. You can customize each brain with the JSON input personality file for different behavior if you want. Even if you use the same input file, each NPC will act a little differently according to what it has “learned”.

Reaction AI with Source code is available now
https://www.assetstore.unity3d.com/en/#!/content/77229