Difference between revisions of "BotProgramming Basics"

From Gladiabots Wiki
Jump to: navigation, search
m (GFX47 moved page Bot programming to BotProgramming Basics)
 
(33 intermediate revisions by one other user not shown)
Line 1: Line 1:
{{Information|This page needs improvement, you are welcome to contribute.}}
 
 
 
== Basics ==
 
== Basics ==
  
 
The robots in ''Gladiabots'' are autonomous and obey their Artificial Intelligence (AI). Bots can only execute one of the [[Game_mechanics#Bot_actions|possible actions]] at a time. The AIs task is to determine what action to use in the current situation. Each bot checks its AI counterclockwise, searching for the first valid branch leading to an action.
 
The robots in ''Gladiabots'' are autonomous and obey their Artificial Intelligence (AI). Bots can only execute one of the [[Game_mechanics#Bot_actions|possible actions]] at a time. The AIs task is to determine what action to use in the current situation. Each bot checks its AI counterclockwise, searching for the first valid branch leading to an action.
  
[[File:Example AI.png|800px]]
+
[[File:Example AI.png|thumb|none|800px|All elements an AI can contain.]]
  
 
The AI of a bot is shaped like an upside down tree. It can be composed of the following elements:
 
The AI of a bot is shaped like an upside down tree. It can be composed of the following elements:
Line 12: Line 10:
 
!Element!!Description
 
!Element!!Description
 
|-
 
|-
|Root node     ||Each AI contains exactly one root node that defines the starting point of the AI check. Nodes linked from the bottom of the root node are evaluated counterclockwise. The root node indicates the name of the AI.
+
|Root node                               ||Each AI contains exactly one root node that defines the starting point of the AI check. Nodes linked from the bottom of the root node are evaluated counterclockwise. The root node indicates the name of the AI.
 
|-
 
|-
|Action node  ||If a rectangular-shaped action node is evaluated valid during AI check, the described action is executed for the current tick. An action node is considered invalid if the bot {{Tooltip|cannot perform it|Example: Attacking an enemy in close range is considered invalid if there are only enemies in mid and long range.}}.
+
|[[Conditions_and_actions|Action node]]   ||If a rectangular-shaped action node is evaluated valid during AI check, the described action is executed for the current tick. An action node is considered invalid if the bot {{Tooltip|cannot perform it|Example: Attacking an enemy in close range is considered invalid if there are only enemies in mid and long range.}}.
 
|-
 
|-
|Condition node||If an oval-shaped condition node is evaluated valid during AI check, the nodes linked from the bottom of the condition node are evaluated counterclockwise. A condition node is considered invalid if the current situation {{Tooltip|doesn't fit it|Example: Checking if an enemy is shooting myself from long range is considered invalid if there is only one enemy shooting myself from mid range.}}.
+
|[[Conditions_and_actions|Condition node]]||If an oval-shaped condition node is evaluated valid during AI check, the nodes linked from the bottom of the condition node are evaluated counterclockwise. A condition node is considered invalid if the current situation {{Tooltip|doesn't fit it|Example: Checking if an enemy is shooting myself from long range is considered invalid if there is only one enemy shooting myself from mid range.}}.
 
|-
 
|-
|Connector node||The diamond-shaped connector node is always evaluated valid during AI check. It connects every node linked to the top of the connector node with every node linked from the bottom of the connector node. A connector node can be used to simplify the layout of the AI.
+
|Connector node                           ||The diamond-shaped connector node is always evaluated valid during AI check. It connects every node linked to the top of the connector node with every node linked from the bottom of the connector node. A connector node can be used to simplify the layout of the AI.
 
|-
 
|-
|Sub-AI node   ||One can reuse an AI inside another one, by using a Sub-AI node. When evaluating this node the whole sub-AI is checked for a valid action. A sub-AI can again contain its own sub-AIs.
+
|Sub-AI node                             ||One can reuse an AI inside another one, by using a Sub-AI node. When evaluating this node the whole sub-AI is checked for a valid action. A sub-AI can again contain its own sub-AIs. Dividing the AI in sub-AIs also improves performance when viewing or editing the AI.
 
|-
 
|-
|Link         ||Nodes can be connected with a link. A link is a directed connection from the bottom of {{Tooltip|one node|Could be a root node, a condition node or a connector node.}} to the top of {{Tooltip|another node|Could be an action node, a condition node, a connector node or a sub-AI node.}}.
+
|Link                                     ||Nodes can be connected with a link. A link is a directed connection from the bottom of {{Tooltip|one node|Could be a root node, a condition node or a connector node.}} to the top of {{Tooltip|another node|Could be an action node, a condition node, a connector node or a sub-AI node.}}.
 
|}
 
|}
  
 
== AI checking process ==
 
== AI checking process ==
  
To determine the action a bot should use in the current situation, the nodes are traversed by a [https://en.wikipedia.org/wiki/Depth-first_search depth-first search] algorithm:
+
[[File:Counterclockwise.png|thumb|Nodes are evaluated counterclockwise]]
 +
[[File:AI check order.png|thumb|Branches are explored with depth-first search]]
 +
 
 +
To determine the action a bot should use in the current situation, the valid nodes are traversed by a [https://en.wikipedia.org/wiki/Depth-first_search depth-first search] algorithm beginning with the root node:
  
 
[[File:Depth-First-Search.gif]]
 
[[File:Depth-First-Search.gif]]
 +
 +
{{InformationCollapsed|1=Details of the AI checking process|2=Use the root node as reference node and start at step (1):
 +
* 1) Get a list of all subnodes linked from the bottom of the reference node. Traverse this list of subnodes ordered {{Tooltip|counterclockwise|Important is the link from the bottom of the reference node to the top of the subnode. The angle is computed between the vertical above the reference node and the link counterclockwise.}}:
 +
** 1a) If the current subnode is an action node and evaluated valid, then the AI checking is discontinued as a '''valid action''' is found.
 +
** 1b) If the current subnode is a sub-AI, then this sub-AI is evaluated. If a '''valid action''' is found in it the AI checking is discontinued.
 +
** 1c) If the current subnode is a condition or connector node and evaluated as valid, then use this subnode as reference node and start a recursive evaluation at step (1). If '''no valid action''' is found there, continue at step (1d) afterwards.
 +
** 1d) If there are further subnodes in step (1) continue with the next subnode at step (1a).
 +
* 2) If there are no further subnodes in step (1), try to backtrack to the previous evaluation in step (1c). If there is no previous evaluation '''no valid action''' could be found. The bot idles instead.
 +
}}
  
 
{{Information|Branches are not executed counterclockwise but checked counterclockwise.}}
 
{{Information|Branches are not executed counterclockwise but checked counterclockwise.}}
  
{{Warning|Rest of the page is a work in progress.}}
+
{{Information|The evaluation of nodes is instant and is not wasting any time from the current tick.}}
 +
 
 +
== Naming AIs ==
 +
 
 +
By adding prefixes like "1 " and "2 " or "A " and "B " in front of the AI name, similar AIs can be shown grouped together for easy selection in the AI list.
 +
 
 +
Possible AI groups:
 +
 
 +
# Main AIs assigned to bots
 +
# Test AIs
 +
# Basic sub-AIs used by many AIs
 +
# Specific sub-AIs used in some AIs
 +
# Sub-AIs used in sub-AIs
 +
# Old AIs not in use anymore
 +
 
 +
Furthermore one of the following elements could be added as prefix, suffix or infix in the AI name:
 +
 
 +
* Bot class (for example: "SN", "SG", "AS", "MG")
 +
* Map name (for example: "7w", "syp", "mp", "...")
 +
* Game version (for example: "9.1", "10.4")
 +
* AI version (for example: "1.4", "3.2")
 +
 
 +
{{InformationCollapsed|1=Chars to use in AI names|2=The following chars can be used in AI names:
 +
* <code><nowiki>!</nowiki></code>, <code><nowiki>#</nowiki></code>, <code><nowiki>$</nowiki></code>, <code><nowiki>%</nowiki></code>, <code><nowiki>&</nowiki></code>, <code><nowiki>(</nowiki></code>, <code><nowiki>)</nowiki></code>, <code><nowiki>*</nowiki></code>, <code><nowiki>,</nowiki></code>, <code><nowiki>.</nowiki></code>,
 +
* <code><nowiki>/</nowiki></code>, <code><nowiki>:</nowiki></code>, <code><nowiki>;</nowiki></code>, <code><nowiki>?</nowiki></code>, <code><nowiki>@</nowiki></code>, <code><nowiki>[</nowiki></code>, <code><nowiki>]</nowiki></code>, <code><nowiki>^</nowiki></code>, <code><nowiki>_</nowiki></code>, <code><nowiki>`</nowiki></code>,
 +
* <code><nowiki>{</nowiki></code>, <code><nowiki>|</nowiki></code>, <code><nowiki>}</nowiki></code>, <code><nowiki>~</nowiki></code>, <code><nowiki>+</nowiki></code>, <code><nowiki>=</nowiki></code>, <code><nowiki>0</nowiki></code>, <code><nowiki>1</nowiki></code>, <code><nowiki>2</nowiki></code>, <code><nowiki>3</nowiki></code>,
 +
* <code><nowiki>4</nowiki></code>, <code><nowiki>5</nowiki></code>, <code><nowiki>6</nowiki></code>, <code><nowiki>7</nowiki></code>, <code><nowiki>8</nowiki></code>, <code><nowiki>9</nowiki></code>, <code><nowiki>-</nowiki></code>, <code><nowiki>a</nowiki></code>, <code><nowiki>A</nowiki></code>, <code><nowiki>b</nowiki></code>,
 +
* <code><nowiki>B</nowiki></code>, <code><nowiki>c</nowiki></code>, <code><nowiki>C</nowiki></code>, <code><nowiki>d</nowiki></code>, <code><nowiki>D</nowiki></code>, <code><nowiki>e</nowiki></code>, <code><nowiki>E</nowiki></code>, <code><nowiki>f</nowiki></code>, <code><nowiki>F</nowiki></code>, <code><nowiki>g</nowiki></code>,
 +
* <code><nowiki>G</nowiki></code>, <code><nowiki>h</nowiki></code>, <code><nowiki>H</nowiki></code>, <code><nowiki>i</nowiki></code>, <code><nowiki>I</nowiki></code>, <code><nowiki>j</nowiki></code>, <code><nowiki>J</nowiki></code>, <code><nowiki>k</nowiki></code>, <code><nowiki>K</nowiki></code>, <code><nowiki>l</nowiki></code>,
 +
* <code><nowiki>L</nowiki></code>, <code><nowiki>m</nowiki></code>, <code><nowiki>M</nowiki></code>, <code><nowiki>n</nowiki></code>, <code><nowiki>N</nowiki></code>, <code><nowiki>o</nowiki></code>, <code><nowiki>O</nowiki></code>, <code><nowiki>p</nowiki></code>, <code><nowiki>P</nowiki></code>, <code><nowiki>q</nowiki></code>,
 +
* <code><nowiki>Q</nowiki></code>, <code><nowiki>r</nowiki></code>, <code><nowiki>R</nowiki></code>, <code><nowiki>s</nowiki></code>, <code><nowiki>S</nowiki></code>, <code><nowiki>t</nowiki></code>, <code><nowiki>T</nowiki></code>, <code><nowiki>u</nowiki></code>, <code><nowiki>U</nowiki></code>, <code><nowiki>v</nowiki></code>,
 +
* <code><nowiki>V</nowiki></code>, <code><nowiki>w</nowiki></code>, <code><nowiki>W</nowiki></code>, <code><nowiki>x</nowiki></code>, <code><nowiki>X</nowiki></code>, <code><nowiki>y</nowiki></code>, <code><nowiki>Y</nowiki></code>, <code><nowiki>z</nowiki></code>, <code><nowiki>Z</nowiki></code>, <code>&nbsp;</code>
  
{{InformationCollapsed|1=Details of the AI checking process|2=Use the root node as reference node and start the following steps:
+
The following chars can '''not''' be used in AI names:
* 1. Get a list of all subnodes linked from the bottom of the reference node.
+
* <code><nowiki>"</nowiki></code>, <code><nowiki>'</nowiki></code>, <code><nowiki><</nowiki></code>, <code><nowiki>></nowiki></code>, <code><nowiki>\</nowiki></code>
* 2. Traverse the list of the subnodes {{Tooltip|counterclockwise|The angle is determined by the link from the bottom of the reference node to the top of the subnode.}}:
+
 
}}
 
}}
  
<!--
+
== Debugging ==
  
 +
It is important to check if the AIs work like intended or if some bugs have sneaked in. To help understanding the AI there are lines drawn from each bot to the target of its current action upon execution.
  
counterclockwise beginning with the root. As long as the nodes are evaluated valid the nodes connected from the bottom are explored below ar
+
=== Debugging window ===
  
are checked recursively starting with the root node as the reference node.
+
By selecting an allied bot one can additionally see the state of its AI. At this point one needs to recall that an AI always uses data from the past. It uses actions from the last tick and the health and shield values as well as the range distances are evaluated at the beginning of the current tick for determining the current action. (for details see [[game mechanics]])
  
 +
=== Debugging sub-AI ===
  
 +
[[File:Debugging AI Ritter Runkel.jpg|thumb|Debugging AI from Ritter Runkel]]
  
* 1) Try to get the first unchecked node
+
To visualize everything a bot did sense when making its decision in the current tick one can create a debugging sub-AI. This will avoid confusion about delay when analyzing an AI.
* 1.1) sdf
+
* 1.2)fgh
+
* 2) fgh
+
  
 +
[[File:Debugging AI Ritter Runkel in action.jpg|thumb|none|800px|Two assaults and a machine gun are attacking the full health and full shield sniper from long range.]]
  
AI checking is discontinued
+
A debugging sub-AI contains:
if not a single action is valid the idle action is used instead.
+
  
describe counterclockwise evaluation process.
+
* ...not a single action node.
and only elements linked to the root node can be evaluated during the execution of the AI
+
* ...condition nodes indicating what the bot senses. Examples:
The evaluation needs no time do not take time to be executed. If they are evaluated as True, the evaluation of the current tree goes on. If they are evaluated as False, the current tree is terminated and the next tree (if any) is evaluated.
+
** Health and shield of self
 +
** Bot class, range and count of enemy bots attacking myself
 +
** Health, shield and range of enemy bot attacked by self
 +
** Actions performed by allied or enemy bots
 +
* ...sub-AIs not connected to the root node
 +
** They point to other important sub-AIs as a quick link.
  
 +
A debugging sub-AI is used in the main AI by linking to it as the very first node that is evaluated from the root node.
  
 +
== Combining condition nodes ==
  
== ToDo ==
+
It is possible to create logic terms like <code>A and B</code> or <code>A or B</code> by combining several condition nodes. In the following examples <code>Is a Sniper attacking me</code> is used as <code>Condition A</code> and <code>Is a Machine gun attacking me</code> is used as <code>Condition B</code>.
  
== Best practices for AI design ==
+
{|class="wikitable"
 +
!Arrangement!!Logic term!!Negated arrangement!!Negated logic term
 +
|-
 +
|{{C}}|[[File:Logic A and B.png|80px]]
 +
|valign='top'|'''A and B'''
  
File:Screenshot 20170712-230926.png
+
Is a Sniper and a Machine gun attacking me?
  
 +
* This arrangement is evaluated '''valid''', if both condition nodes are evaluated '''valid'''.
 +
* This arrangement is evaluated '''invalid''', if one or both of the conditions are evaluated '''invalid'''.
  
== Subtrees / Sub-AIs ==
+
|{{C}}|[[File:Logic not (A and B).png|180px]]
 +
|valign='top'|'''not (A and B)'''
  
 +
The opposite of the arrangement "Is a Sniper and a Machine gun attacking me?" is: Is there no Sniper attacking me or is there no Machine gun attacking me.
  
Links:
+
* This arrangement is evaluated '''invalid''', if both condition nodes are evaluated '''valid'''.
 +
* This arrangement is evaluated '''valid''', if one or both of the conditions are evaluated '''invalid'''.
  
debugging If a bot is selected one can see the state of its AI. - lines between bots
+
|-
Connectors Though they do not execute any computation or action, they have an interesting, though not commonly used or advised, use.
+
|{{C}}|[[File:Logic A or B.png|180px]]
Connectors are the GOTOs of AIs. And just like any programming language, GOTOs here too are considered "bad" code. Still, they can save you a lot of work sometimes.
+
|valign='top'|'''A or B'''
Ever have a group of Nodes that you regularly use, and the same thing is present in your AI again and again? Sub-AIs are used like Macros. You can just make an AI with the commonly used group of Nodes, and then add this as a Sub-AI in your main AI. Sub-AIs tend to improve game performance (more Nodes make the game laggier)
+
You can also use Sub-AIs to make Hybrids out of existing AIs. Remember, Sub-AIs are essentially AIs linking other AIs.
+
  
 +
Is a Sniper or a Machine gun attacking me?
  
Readable code. To be readable avoid crossing lines. Divide in sub-AIs
+
* This arrangement is evaluated '''valid''', if one or both of the conditions are evaluated '''valid'''.
> Comment it with empty sub-AIs
+
* This arrangement is evaluated '''invalid''', if both condition nodes are evaluated '''invalid'''.
  
 +
|{{C}}|[[File:Logic not (A or B).png|80px]]
 +
|valign='top'|'''not (A or B)'''
  
Bots are created using the AI Editor.
+
The opposite of the arrangement "Is a Sniper or a Machine gun attacking me?" is: Is there no Sniper attacking me and is there no Machine gun attacking me.
The AI editor is where you design your AIs.
+
  
 +
* This arrangement is evaluated '''invalid''', if one or both of the conditions are evaluated '''valid'''.
 +
* This arrangement is evaluated '''valid''', if both condition nodes are evaluated '''invalid'''.
  
=== Conditions and actions ===
+
|-
 +
|{{C}}|[[File:Logic A xor B.png|180px]]
 +
|valign='top'|'''A xor B'''
  
 +
Is either a Sniper or a Machine gun but not both of them attacking me?
  
Conditions are in syntax
+
* This arrangement is evaluated '''valid''', if exactly one of the conditions is evaluated '''valid'''.
<code>Target(Filters)-Condition(Evaluation)</code>
+
* This arrangement is evaluated '''invalid''', if none or both condition nodes are evaluated '''valid'''.
  
Target - The type of Gladiabots Entity (Ally, Enemy, AllyBase, EnemyBase, Resource) to be checked
+
|{{C}}|[[File:Logic not (A xor B).png|180px]]
Filters - Criteria that the target has to meet
+
|valign='top'|'''not (A xor B)'''
Condition - Action that the Target is executing
+
Evaluation - Checking the [Invert] check box makes the Condition evaluate True if the filtered Target is <i>not</i> executing the action mentioned in the Condition.
+
  
* Aiming is seen as Attacking
+
The opposite of the arrangement "Is either a Sniper or a Machine gun but not both of them attacking me?" is: Is there a Sniper attacking me and is there a Machine gun attacking me or is there no Sniper attacking me and is there no Machine gun attacking me.
  
-->
+
* This arrangement is evaluated '''invalid''', if exactly one of the conditions is evaluated '''valid'''.
 +
* This arrangement is evaluated '''valid''', if none or both condition nodes are evaluated '''valid'''.
 +
 
 +
|}
 +
 
 +
=== Truth table ===
 +
 
 +
{|class="wikitable"
 +
!Description!!Sniper!!Machine gun!!A and B!!not (A and B)!!A or B!!not (A or B)!!A xor B!!not (A xor B)
 +
|-
 +
|There is a Sniper and a Machine gun. ||{{X}}||{{X}}||{{X}}||{{I}}||{{X}}||{{I}}||{{I}}||{{X}}
 +
|-
 +
|There is a Sniper but no Machine gun.||{{X}}||{{I}}||{{I}}||{{X}}||{{X}}||{{I}}||{{X}}||{{I}}
 +
|-
 +
|There is a Machine gun but no Sniper.||{{I}}||{{X}}||{{I}}||{{X}}||{{X}}||{{I}}||{{X}}||{{I}}
 +
|-
 +
|There is no Sniper nor a Machine gun.||{{I}}||{{I}}||{{I}}||{{X}}||{{I}}||{{X}}||{{I}}||{{X}}
 +
|}

Latest revision as of 08:56, 15 June 2020

Basics

The robots in Gladiabots are autonomous and obey their Artificial Intelligence (AI). Bots can only execute one of the possible actions at a time. The AIs task is to determine what action to use in the current situation. Each bot checks its AI counterclockwise, searching for the first valid branch leading to an action.

All elements an AI can contain.

The AI of a bot is shaped like an upside down tree. It can be composed of the following elements:

Element Description
Root node Each AI contains exactly one root node that defines the starting point of the AI check. Nodes linked from the bottom of the root node are evaluated counterclockwise. The root node indicates the name of the AI.
Action node If a rectangular-shaped action node is evaluated valid during AI check, the described action is executed for the current tick. An action node is considered invalid if the bot cannot perform it.
Condition node If an oval-shaped condition node is evaluated valid during AI check, the nodes linked from the bottom of the condition node are evaluated counterclockwise. A condition node is considered invalid if the current situation doesn't fit it.
Connector node The diamond-shaped connector node is always evaluated valid during AI check. It connects every node linked to the top of the connector node with every node linked from the bottom of the connector node. A connector node can be used to simplify the layout of the AI.
Sub-AI node One can reuse an AI inside another one, by using a Sub-AI node. When evaluating this node the whole sub-AI is checked for a valid action. A sub-AI can again contain its own sub-AIs. Dividing the AI in sub-AIs also improves performance when viewing or editing the AI.
Link Nodes can be connected with a link. A link is a directed connection from the bottom of one node to the top of another node.

AI checking process

Nodes are evaluated counterclockwise
Branches are explored with depth-first search

To determine the action a bot should use in the current situation, the valid nodes are traversed by a depth-first search algorithm beginning with the root node:

Depth-First-Search.gif

Information.png
Details of the AI checking process 

Use the root node as reference node and start at step (1):

  • 1) Get a list of all subnodes linked from the bottom of the reference node. Traverse this list of subnodes ordered counterclockwise:
    • 1a) If the current subnode is an action node and evaluated valid, then the AI checking is discontinued as a valid action is found.
    • 1b) If the current subnode is a sub-AI, then this sub-AI is evaluated. If a valid action is found in it the AI checking is discontinued.
    • 1c) If the current subnode is a condition or connector node and evaluated as valid, then use this subnode as reference node and start a recursive evaluation at step (1). If no valid action is found there, continue at step (1d) afterwards.
    • 1d) If there are further subnodes in step (1) continue with the next subnode at step (1a).
  • 2) If there are no further subnodes in step (1), try to backtrack to the previous evaluation in step (1c). If there is no previous evaluation no valid action could be found. The bot idles instead.
Information.png Branches are not executed counterclockwise but checked counterclockwise.
Information.png The evaluation of nodes is instant and is not wasting any time from the current tick.

Naming AIs

By adding prefixes like "1 " and "2 " or "A " and "B " in front of the AI name, similar AIs can be shown grouped together for easy selection in the AI list.

Possible AI groups:

  1. Main AIs assigned to bots
  2. Test AIs
  3. Basic sub-AIs used by many AIs
  4. Specific sub-AIs used in some AIs
  5. Sub-AIs used in sub-AIs
  6. Old AIs not in use anymore

Furthermore one of the following elements could be added as prefix, suffix or infix in the AI name:

  • Bot class (for example: "SN", "SG", "AS", "MG")
  • Map name (for example: "7w", "syp", "mp", "...")
  • Game version (for example: "9.1", "10.4")
  • AI version (for example: "1.4", "3.2")
Information.png
Chars to use in AI names 

The following chars can be used in AI names:

  • !, #, $, %, &, (, ), *, ,, .,
  • /, :, ;, ?, @, [, ], ^, _, `,
  • {, |, }, ~, +, =, 0, 1, 2, 3,
  • 4, 5, 6, 7, 8, 9, -, a, A, b,
  • B, c, C, d, D, e, E, f, F, g,
  • G, h, H, i, I, j, J, k, K, l,
  • L, m, M, n, N, o, O, p, P, q,
  • Q, r, R, s, S, t, T, u, U, v,
  • V, w, W, x, X, y, Y, z, Z,  

The following chars can not be used in AI names:

  • ", ', <, >, \

Debugging

It is important to check if the AIs work like intended or if some bugs have sneaked in. To help understanding the AI there are lines drawn from each bot to the target of its current action upon execution.

Debugging window

By selecting an allied bot one can additionally see the state of its AI. At this point one needs to recall that an AI always uses data from the past. It uses actions from the last tick and the health and shield values as well as the range distances are evaluated at the beginning of the current tick for determining the current action. (for details see game mechanics)

Debugging sub-AI

Debugging AI from Ritter Runkel

To visualize everything a bot did sense when making its decision in the current tick one can create a debugging sub-AI. This will avoid confusion about delay when analyzing an AI.

Two assaults and a machine gun are attacking the full health and full shield sniper from long range.

A debugging sub-AI contains:

  • ...not a single action node.
  • ...condition nodes indicating what the bot senses. Examples:
    • Health and shield of self
    • Bot class, range and count of enemy bots attacking myself
    • Health, shield and range of enemy bot attacked by self
    • Actions performed by allied or enemy bots
  • ...sub-AIs not connected to the root node
    • They point to other important sub-AIs as a quick link.

A debugging sub-AI is used in the main AI by linking to it as the very first node that is evaluated from the root node.

Combining condition nodes

It is possible to create logic terms like A and B or A or B by combining several condition nodes. In the following examples Is a Sniper attacking me is used as Condition A and Is a Machine gun attacking me is used as Condition B.

Arrangement Logic term Negated arrangement Negated logic term
Logic A and B.png A and B

Is a Sniper and a Machine gun attacking me?

  • This arrangement is evaluated valid, if both condition nodes are evaluated valid.
  • This arrangement is evaluated invalid, if one or both of the conditions are evaluated invalid.
Logic not (A and B).png not (A and B)

The opposite of the arrangement "Is a Sniper and a Machine gun attacking me?" is: Is there no Sniper attacking me or is there no Machine gun attacking me.

  • This arrangement is evaluated invalid, if both condition nodes are evaluated valid.
  • This arrangement is evaluated valid, if one or both of the conditions are evaluated invalid.
Logic A or B.png A or B

Is a Sniper or a Machine gun attacking me?

  • This arrangement is evaluated valid, if one or both of the conditions are evaluated valid.
  • This arrangement is evaluated invalid, if both condition nodes are evaluated invalid.
Logic not (A or B).png not (A or B)

The opposite of the arrangement "Is a Sniper or a Machine gun attacking me?" is: Is there no Sniper attacking me and is there no Machine gun attacking me.

  • This arrangement is evaluated invalid, if one or both of the conditions are evaluated valid.
  • This arrangement is evaluated valid, if both condition nodes are evaluated invalid.
Logic A xor B.png A xor B

Is either a Sniper or a Machine gun but not both of them attacking me?

  • This arrangement is evaluated valid, if exactly one of the conditions is evaluated valid.
  • This arrangement is evaluated invalid, if none or both condition nodes are evaluated valid.
Logic not (A xor B).png not (A xor B)

The opposite of the arrangement "Is either a Sniper or a Machine gun but not both of them attacking me?" is: Is there a Sniper attacking me and is there a Machine gun attacking me or is there no Sniper attacking me and is there no Machine gun attacking me.

  • This arrangement is evaluated invalid, if exactly one of the conditions is evaluated valid.
  • This arrangement is evaluated valid, if none or both condition nodes are evaluated valid.

Truth table

Description Sniper Machine gun A and B not (A and B) A or B not (A or B) A xor B not (A xor B)
There is a Sniper and a Machine gun.
There is a Sniper but no Machine gun.
There is a Machine gun but no Sniper.
There is no Sniper nor a Machine gun.