Difference between revisions of "BotProgramming Basics"
From Gladiabots Wiki
Line 14: | Line 14: | ||
!Element!!Description | !Element!!Description | ||
|- | |- | ||
− | |Root node ||Each AI contains exactly one root node that defines the | + | |Root node ||Each AI contains exactly one root node that defines the starting point of the AI check. It contains 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.}}. | |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 elements connected 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.}}. | + | |Condition node||If an oval-shaped condition node is evaluated valid during AI check, the elements connected from the bottom side 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 element linked to the | + | |Connector node||The diamond-shaped connector node is always evaluated valid during AI check. It connects every element linked to the upper side with every element linked from the bottom side of the connector node. A connector node can be used to simplify the layout of the AI. |
|- | |- | ||
− | |Sub-AI node || | + | |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. |
|- | |- | ||
− | |Link || | + | |Link ||A link connects the bottom side of {{Tooltip|one node|Could be a root node, condition node or connector node.}} with the upper side of {{Tooltip|another node|Could be a action node, condition node, connector node or sub-AI node.}}. |
|} | |} | ||
<!-- | <!-- | ||
+ | |||
+ | add output / Input and signal | ||
== ToDo == | == ToDo == | ||
+ | == AI checking process == | ||
+ | == Best practices for AI design == | ||
+ | |||
+ | File:Screenshot 20170712-230926.png | ||
+ | AI checking is discontinued | ||
+ | if not a single action is valid the idle action is used instead. | ||
== Subtrees / Sub-AIs == | == Subtrees / Sub-AIs == | ||
− | + | ||
− | + | ||
− | + | ||
Links: Nodes can be connected with a link. | Links: Nodes can be connected with a link. | ||
Line 46: | Line 52: | ||
Connectors Though they do not execute any computation or action, they have an interesting, though not commonly used or advised, use. | Connectors Though they do not execute any computation or action, they have an interesting, though not commonly used or advised, use. | ||
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. | 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. | ||
+ | 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. | ||
+ | |||
+ | |||
Readable code. To be readable avoid crossing lines. Divide in sub-AIs | Readable code. To be readable avoid crossing lines. Divide in sub-AIs | ||
> Comment it with | > Comment it with |
Revision as of 08:19, 19 October 2017
![]() |
This page needs improvement, you are welcome to contribute. |
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.
![]() |
Rest of the page is a work in progress. |
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. It contains 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 elements connected from the bottom side 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 element linked to the upper side with every element linked from the bottom side 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. |
Link | A link connects the bottom side of one node![]() ![]() |