Difference between revisions of "BotProgramming Basics"
From Gladiabots Wiki
Line 28: | Line 28: | ||
[[File:Counterclockwise.png|thumb|Nodes are evaluated counterclockwise]] | [[File:Counterclockwise.png|thumb|Nodes are evaluated counterclockwise]] | ||
+ | [[File:AI check order.png|thumb|Branches are explored with depth-first search]] | ||
To determine the action a bot should use in the current situation, the valid nodes are traversed by a [https://en.wikipedia.org/wiki/Depth-first_search depth-first search] algorithm beginning with the root node: | To determine the action a bot should use in the current situation, the valid nodes are traversed by a [https://en.wikipedia.org/wiki/Depth-first_search depth-first search] algorithm beginning with the root node: | ||
Line 57: | Line 58: | ||
<!-- | <!-- | ||
− | |||
− | |||
== Best practices for AI design == | == Best practices for AI design == | ||
+ | |||
+ | Code conventions improve the readability of the software, allowing engineers to understand new code more quickly and thoroughly. | ||
+ | |||
+ | Complexity is the enemy of security.[3] | ||
+ | |||
+ | The management of complexity is very important. There is a very basic principle - during the project development ask the question - "has this project been implemented with the least amount of code necessary ?". If it hasn't then unnecessary work has been undertaken and unnecessary cost - both upfront and downstream - has been incurred. This is the "Keep it Simple" rule - simple but effective. | ||
+ | |||
+ | The more complex the code is the more likely it is to be buggy, the more difficult the bugs are to find and the more likely there are to be hidden bugs. Safe coding is very important. | ||
+ | |||
+ | Formating code | ||
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. |
Revision as of 09:03, 21 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. |
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
![]() |
Rest of the page is a work in progress. |