Difference between revisions of "BotProgramming Basics"
Line 101: | Line 101: | ||
One needs to recall that an AI always uses values of 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]]) | One needs to recall that an AI always uses values of 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]]) | ||
+ | |||
+ | [[File:Debugging AI Ritter Runkel in action.jpg|800px]] | ||
To avoid confusion about this delay when analyzing an AI, one can create a debugging sub-AI showing each value the AI used for its decision in the current tick: | To avoid confusion about this delay when analyzing an AI, one can create a debugging sub-AI showing each value the AI used for its decision in the current tick: | ||
+ | |||
+ | |||
+ | |||
+ | <!-- | ||
+ | |||
+ | [[File:Debugging AI Ritter Runkel in action.jpg]] | ||
+ | [[File:Debugging AI Ritter Runkel.jpg]] | ||
+ | |||
+ | Chat: | ||
+ | Left side is enemy I'm attacking, middle is own Shields and health and on the right side are all the enemies attacking me with a counter for the Assaults. | ||
+ | On the bottom I have pointers to my standard subtrees | ||
+ | But how do you know how to react on which situations. Especially due to the fact that there is one tick delay between actions and filters? | ||
+ | You can't know then what your bot is sensing? | ||
+ | The healthbars, lines, and range circles tells me enough | ||
+ | But you see these things one tick before your bot sees it | ||
+ | In this case, two assaults and one mg are attacking the sniper from long range | ||
+ | |||
+ | |||
+ | --> | ||
+ | |||
+ | |||
{{Warning|The rest of the page is a work in progress.}} | {{Warning|The rest of the page is a work in progress.}} | ||
Line 178: | Line 201: | ||
|There is no Sniper nor a Machine gun.||{{I}}||{{I}}||{{I}}||{{X}}||{{I}}||{{X}}||{{I}}||{{X}} | |There is no Sniper nor a Machine gun.||{{I}}||{{I}}||{{I}}||{{X}}||{{I}}||{{X}}||{{I}}||{{X}} | ||
|} | |} | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− |
Revision as of 21:27, 24 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
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. By selecting an allied bot one can additionally see the state of its AI.
One needs to recall that an AI always uses values of 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)
To avoid confusion about this delay when analyzing an AI, one can create a debugging sub-AI showing each value the AI used for its decision in the current tick:
![]() |
The rest of the page is a work in progress. |
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
.
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. | ✖ | ✖ | ✖ | ✔ | ✖ | ✔ | ✖ | ✔ |