Difference between revisions of "BotProgramming Basics"
Line 125: | Line 125: | ||
== Combining condition nodes == | == Combining condition nodes == | ||
− | + | Any 2 condition nodes can be combined several nodes | |
+ | |||
+ | [[File:Logic A and B.png|100px]] | ||
+ | [[File:Logic not (A and B).png|225px]] | ||
+ | [[File:Logic A or B.png|225px]] | ||
+ | [[File:Logic not (A or B).png|100px]] | ||
+ | [[File:Logic A xor B.png|225px]] | ||
+ | [[File:Logic not (A xor B).png|225px]] | ||
+ | |||
+ | OR gate | ||
+ | This arrangements of condition nodes will execute the action when one or both condition nodes are true, but not when both are false. | ||
+ | AND gate | ||
+ | This arrangement of condition nodes will only execute the action when both condition nodes are true, but will not when one or both are false. | ||
+ | ExOR gate | ||
+ | This arrangement of nodes will only execute the action if either one of the top condition nodes are true, but not if both are true, or if both are false. | ||
+ | ExNOR | ||
+ | This arrangement of nodes will only execute the action when both condition nodes are true or false, and not when only one condition is true. | ||
+ | NAND gate | ||
+ | This arrangement of nodes will only execute the action when both conditions are false, or one of the conditions are true, and not when both conditions are true. (Ranges of HP for example can be obtained by adding values in parallel, like a mini OR) | ||
+ | NOT gate | ||
+ | This arrangement of nodes will only execute the action when the inverted condition node is true, and not when the original condition node is true. (in this case true when enemy not at mid range) | ||
+ | NOR gate | ||
+ | This arrangement of nodes will only execute the action when both conditions are false (inverted conditions are true), and not when 1 or both are true (inverted conditions are false). | ||
+ | |||
+ | I'm not sure what you mean with priority in this case ? You have 4 possible scenarios : | ||
+ | If there is no MG nor Sniper : Left is true (since there is no MG) so you push | ||
+ | If there is a MG but no Sniper : Left is false, right is true (since there is no sniper) so you push | ||
+ | If there is no MG but there is a Sniper : Left is true, right is false so you push | ||
+ | If there is a MG and a Sniper : Left is false, right is false -> don't push | ||
--> | --> |
Revision as of 20:12, 22 October 2017
![]() |
This page needs improvement, you are welcome to contribute. |
Contents
[hide]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.
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![]() ![]() |
AI checking process
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:
![]() |
|
![]() |
Branches are not executed counterclockwise but checked counterclockwise. |
![]() |
The evaluation of nodes is instant and is not wasting any time from the current tick. |
Best practices for AI design
Some best coding practices from software development also apply to AIs in Gladiabots. The following rules can help improve the quality of AIs, enhancing both the initial development and subsequent maintenance of the AI.
![]() |
|
![]() |
|
![]() |
|
![]() |
|
![]() |
|
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")
![]() |
|
Debugging AIs
![]() |
The rest of the page is a work in progress. |