Difference between revisions of "BotProgramming Basics"

From Gladiabots Wiki
Jump to: navigation, search
Line 16: Line 16:
 
|Root node    ||Each AI contains exactly one root node that defines the AIs starting point. It contains the name of the AI.  
 
|Root node    ||Each AI contains exactly one root node that defines the AIs starting point. It contains the name of the AI.  
 
|-
 
|-
|Action node  ||If a rectangular-shaped action node is evaluated true, 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, 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 true, the elements connected to the bottom of the condition 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, the elements connected to the bottom of the condition 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    ||
+
|Connector    ||The diamond-shaped connector can be used to simplify the layout of the AI. It connects every element linked to the top of the connector with every element linked from the bottom of the connector. A connector will always be considered valid during AI check.
 
|-
 
|-
 
|Sub-AI        ||
 
|Sub-AI        ||
Line 30: Line 30:
 
<!--
 
<!--
 
== ToDo ==
 
== ToDo ==
 
== Connectors ==
 
A connector node can be used to simplify the layout of the AI. A connector will always be considered valid during AI check.
 
They are always evaluated as "True". 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.
 
  
 
== Subtrees / Sub-AIs ==
 
== Subtrees / Sub-AIs ==
Line 49: Line 44:
 
and only elements linked to the root node can be evaluated during the execution of the AI
 
and only elements linked to the root node can be evaluated during the execution of the AI
 
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.
 
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.
 
+
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.
 +
Readable code. To be readable avoid crossing lines. Divide in sub-AIs
 +
> Comment it with
  
  

Revision as of 07:37, 19 October 2017

Information.png 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.

Example AI.png

Warning.png 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 AIs starting point. It contains the name of the AI.
Action node If a rectangular-shaped action node is evaluated valid, 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, the elements connected to the bottom of the condition are evaluated counterclockwise. A condition node is considered invalid if the current situation doesn't fit it.
Connector The diamond-shaped connector can be used to simplify the layout of the AI. It connects every element linked to the top of the connector with every element linked from the bottom of the connector. A connector will always be considered valid during AI check.
Sub-AI
Link