Difference between revisions of "BotProgramming Basics"

From Gladiabots Wiki
Jump to: navigation, search
Line 26: Line 26:
  
 
== AI checking process ==
 
== AI checking process ==
 +
 +
[[File:Counterclockwise.png|thumb|Nodes are evaluated counterclockwise]]
  
 
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:
 
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:
Line 36: Line 38:
  
 
{{InformationCollapsed|1=Details of the AI checking process|2=Use the root node as reference node and start the following steps:
 
{{InformationCollapsed|1=Details of the AI checking process|2=Use the root node as reference node and start the following steps:
* 1. Get a list of all subnodes linked from the bottom of the reference node.
+
* 1) Get a list of all subnodes linked from the bottom of the reference node.
* 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.}}:
+
* 2) Traverse the list of the subnodes ordered {{Tooltip|counterclockwise|The angle is determined by the link from the bottom of the reference node to the top of the subnode.}}:
 +
* 2.1) If the current subnode is of type action node and evaluated valid, then the search is discontinued as a valid action is found.
 +
* 2.2) If the current subnode is of type sub-AI, then this sub-AI is evaluated. If a valid action is found the search is discontinued.
 +
* 2.3) If the current subnode is of type condition or connector node and evaluated as valid, then use this sub node as reference node and start a recursive evaluation at step (1).
 +
* 2.4) If there are further subnodes in step (2) continue with the next subnode.
 +
* 3) If there was no valid action up to this point, let the bot idle instead.
 
}}
 
}}
  
Line 43: Line 50:
  
  
 +
[[File:Screenshot 20170712-230926.png]]
 
counterclockwise beginning with the root. As long as the nodes are evaluated valid the nodes connected from the bottom are explored below ar
 
counterclockwise beginning with the root. As long as the nodes are evaluated valid the nodes connected from the bottom are explored below ar
  
Line 68: Line 76:
 
== Best practices for AI design ==
 
== Best practices for AI design ==
  
File:Screenshot 20170712-230926.png
+
[[File:Screenshot 20170712-230926.png]]
  
  

Revision as of 23:43, 20 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

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

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

Depth-First-Search.gif

Information.png Branches are not executed counterclockwise but checked counterclockwise.
Warning.png Rest of the page is a work in progress.
Information.png
Details of the AI checking process 

Use the root node as reference node and start the following steps:

  • 1) Get a list of all subnodes linked from the bottom of the reference node.
  • 2) Traverse the list of the subnodes ordered counterclockwise:
  • 2.1) If the current subnode is of type action node and evaluated valid, then the search is discontinued as a valid action is found.
  • 2.2) If the current subnode is of type sub-AI, then this sub-AI is evaluated. If a valid action is found the search is discontinued.
  • 2.3) If the current subnode is of type condition or connector node and evaluated as valid, then use this sub node as reference node and start a recursive evaluation at step (1).
  • 2.4) If there are further subnodes in step (2) continue with the next subnode.
  • 3) If there was no valid action up to this point, let the bot idle instead.