# How do I Invert a Guard in GDX-AI?

I am trying to define an AI behavior where if a conditional (MyCondition) is false, execute the task. I know I can do this as follows:

import myCondition?:"tech.otter.something.MyCondition"
import otherTask:"tech.otter.something.OtherTask"

root
selector
myCondition? # i.e. if !myCondition then otherTask
otherTask


Now I'd like to use the snazzy guard syntax like so:

root
(myCondition?) otherTask


The problem is that I really need otherTask to fire when the guard (myCondition?) is false. Is there a way to do this shy of defining a "MyInvertedCondition" task?

## 1 Answer

This can be achieved using decorators which can be read about here. I believe the syntax would be like this: (invert MyCondition).

If that doesn't work you can always use a subtree as your guard. The syntax would then be like this:

subtree name:"Invertedguard"
invert MyCondition?

(\$Invertedguard)