Difference between revisions of "Strategies"

From Gladiabots Wiki
Jump to: navigation, search
 
(10 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 +
== 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.
 +
 +
{{InformationCollapsed|1=Divide and conquer.|2=Break down a problem into two or more sub-problems and solve each of them separately. Complex sub-problems can again be divided. In ''Gladiabots'' this could be done by creating sub-AIs for each sub-problem. The complexity is reduced leading to a better maintainability.}}
 +
 +
{{InformationCollapsed|1=Readability first.|2=AIs are written once, but read many times. Overlapping nodes, links crossing each other and great distances between linked nodes are difficult to read and should be avoided. AIs should have meaningful names revealing their purpose. One should consider to align nodes to the grid.}}
 +
 +
{{InformationCollapsed|1=Don't repeat yourself.|2=Avoid using the exact same set of nodes in several places. Sometimes duplicate nodes can be prevented by using bot specific filters or additional conditions. If its not possible to prevent duplicate nodes in the first place one can try to move them to sub AIs.}}
 +
 +
{{InformationCollapsed|1=Keep it simple.|2=The size of an AI has a significant effect on the error rate. A simple solution should be preferred over a complex one leading to the same or very similar results. One should ask the question: "Has this AI been implemented with the least amount of nodes necessary?". The more complex the AI is the more likely it is to be buggy.}}
 +
 +
{{InformationCollapsed|1=Test, test, test.|2="If debugging is the process of removing bugs, then programming must be the process of putting them in." (Edsger Wybe Dijkstra) As no developer is perfect, new nodes should be tested and debugged right after they were added.}}
 +
 +
== Micro or Macro ==
 +
 +
A macro strategy uses a few nodes to do a lot of things approximately, a micro strategy uses lots of nodes to do one thing well. You need both to be great. Try thinking how you can replace a small amount nodes with a more precise sub-AI, but when you have a new idea, try starting small and finding a good default.
 +
 +
Some players will naturally be better at one or the other. Remember that you can always find friends to help you out.
 +
 
== Ideas worth implementing ==
 
== Ideas worth implementing ==
  
Line 11: Line 31:
 
{{InformationCollapsed|1=Minimize the time spend switching attack targets.|2=Usually a bot should continuously attack the bot it started to attack. (by filtering a target attacked in the previous tick) Create strict rules for when to switch targets. For the sniper and machine gun, whose reload time is quite long, it's especially important.}}
 
{{InformationCollapsed|1=Minimize the time spend switching attack targets.|2=Usually a bot should continuously attack the bot it started to attack. (by filtering a target attacked in the previous tick) Create strict rules for when to switch targets. For the sniper and machine gun, whose reload time is quite long, it's especially important.}}
  
{{InformationCollapsed|1=Focus fire.|2=Prioritize enemies that are already being attacked by your allies. Also prioritize enemies with 0-25% shield.}}
+
{{InformationCollapsed|1=Focus fire.|2=Prioritize enemies that are already being attacked by your allies or prioritize enemies with low shield.}}
 
+
{{InformationCollapsed|1=Focus the enemy sniper.|2=Pay a lot of attention to your opponent's sniper. Your sniper should prioritize attacking the enemies sniper. If your sniper hits the opponent's sniper then it's probably worth changing the attack target of all your nearby units to it, even if they are attacking medium range units. (and only if it is safe/worthwhile doing so)}}
+
  
 
=== Push ===
 
=== Push ===
Line 21: Line 39:
 
{{InformationCollapsed|1=Push in the right moment.|2=Don't push when being attacked. Sometimes the pushing process should be aborted, because too many enemies are around.}}
 
{{InformationCollapsed|1=Push in the right moment.|2=Don't push when being attacked. Sometimes the pushing process should be aborted, because too many enemies are around.}}
  
{{InformationCollapsed|1=Flank or circle bots.|2=Flanked and circled bots get easily destroyed. For flanking moves one can use an {{Tooltip|APS|Arena Positioning System}} (use a combination of moving to and fleeing from bases, resources and bots to navigate).}}
+
{{InformationCollapsed|1=Flank or circle bots.|2=Flanked and circled bots get easily destroyed. Try to avoid pushing too aggressively, so you don't get caught between two enemies.}}
  
=== Resources ===
+
=== Collection ===
  
{{InformationCollapsed|1=Score wisely|2=Mid game scoring has pros and cons. Scoring to much leaves you defenseless against an aggressively pushing enemy. Scoring not at all will probably result in a game lost 0:1. Keep an eye on the health values of your bots and if the enemy team is scoring.}}
+
{{InformationCollapsed|1=Score wisely|2=Try to score to bases away from the enemy, but not so far away that you spend valuable time carrying the resource there.}}
  
 
{{InformationCollapsed|1=Score unexpected|2=Try to rush for early resources or smuggle resources mid game. Sometimes also picking 2 or 3 resources at once works.}}
 
{{InformationCollapsed|1=Score unexpected|2=Try to rush for early resources or smuggle resources mid game. Sometimes also picking 2 or 3 resources at once works.}}
  
=== Shotgun ===
+
=== Domination ===
  
{{InformationCollapsed|1=Shoot at second sight|2=The shotgun should not always start shooting at the first bot it sees at medium range. Its good to get as close as you can to medium range units, especially if they are retreating or being attacked by an ally. This will give your shotgun more medium range shots as the enemy unit tries to escape from medium range. For example only stop moving towards medium range units when at least 2 units are in medium range.}}
+
{{InformationCollapsed|1=Go for bases|2=You get points for bots being on bases, so any time spent outside bases is wasted time.}}
  
=== General ===
+
{{InformationCollapsed|1=Find the right force fields|2=Not all force fields are equal, find the ones that cover multiple bases.}}
  
{{InformationCollapsed|1=Think about maintainability.|2=Don't use to complicated structures, map and bot specific stuff. It's easier to make one generic AI then to handle a truckload of specialized ones.}}
+
=== Elimination ===
  
{{InformationCollapsed|1=Decorate a generic AI.|2=The [https://en.wikipedia.org/wiki/Decorator_pattern decorator pattern] can be used to add flexibility to a generic AI. A decorator is a simple program to tell a bot what to do at the start of the map. Afterwards (indicated by tags) it uses the main AI included as a sub AI.}}
+
{{InformationCollapsed|1=Know when to shoot|2=The less you shoot, the more you push. It's often more important to know when to shoot than who to shoot.}}
  
{{InformationCollapsed|1=Ignore tagging.|2=New players can totally ignore tagging. (especially for combat) They will probably waste a lot of time (ticks) using them.}}
+
{{InformationCollapsed|1=Work as a group|2=Bots together cancel each other's weaknesses. Keep your bots together.}}
  
{{InformationCollapsed|1=Start experimenting.|2=Don't follow rules. Sometimes you have to break a rule to dominate. Some rules also have cons one should be wary about.}}
+
=== Shotgun ===
  
== Best practices for AI design ==
+
{{InformationCollapsed|1=Shoot at second sight|2=The shotgun should not always start shooting at the first bot it sees at medium range. Its good to get as close as you can to medium range units, especially if they are retreating or being attacked by an ally. This will give your shotgun more medium range shots as the enemy unit tries to escape from medium range. For example only stop moving towards medium range units when at least 2 units are in medium range.}}
  
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.
+
=== Sniper ===
  
{{InformationCollapsed|1=Divide and conquer.|2=Break down a problem into two or more sub-problems and solve each of them separately. Complex sub-problems can again be divided. In ''Gladiabots'' this could be done by creating sub-AIs for each sub-problem. The complexity is reduced leading to a better maintainability.}}
+
{{InformationCollapsed|1=Focus on the enemy sniper|2=Pay a lot of attention to your opponent's sniper. Your sniper should prioritize attacking the enemies sniper. If your sniper hits the opponent's sniper then it's probably worth changing the attack target of all your nearby units to it, even if they are attacking medium range units. (and only if it is safe/worthwhile doing so)}}
  
{{InformationCollapsed|1=Readability first.|2=AIs are written once, but read many times. Overlapping nodes, links crossing each other and great distances between linked nodes are difficult to read and should be avoided. AIs should have meaningful names revealing their purpose. One should consider to align nodes to the grid.}}
+
=== Machine Gun ===
  
{{InformationCollapsed|1=Don't repeat yourself.|2=Avoid using the exact same set of nodes in several places. Sometimes duplicate nodes can be prevented by using bot specific filters or additional conditions. If its not possible to prevent duplicate nodes in the first place one can try to move them to sub AIs.}}
+
{{InformationCollapsed|1=Hold your ground|2=Machine guns are great at holding positions or bases.}}
  
{{InformationCollapsed|1=Keep it simple.|2=The size of an AI has a significant effect on the error rate. A simple solution should be preferred over a complex one leading to the same or very similar results. One should ask the question: "Has this AI been implemented with the least amount of nodes necessary?". The more complex the AI is the more likely it is to be buggy.}}
+
{{InformationCollapsed|1=Carry resources|2=Machine guns are the fastest bot to score resources (but not to grab).}}
  
{{InformationCollapsed|1=Test, test, test.|2="If debugging is the process of removing bugs, then programming must be the process of putting them in." (Edsger Wybe Dijkstra) As no developer is perfect, new nodes should be tested and debugged right after they were added.}}
+
=== General ===
  
== Simple bots ==
+
{{InformationCollapsed|1=Think about maintainability|2=Don't use to complicated structures, map and bot specific stuff. It's easier to make one generic AI then to handle a truckload of specialized ones.}}
  
One can learn of bots with few nodes that have a pretty good performance in the game. They are a great base to start optimizing for beginners but also for advanced players to test their AI against.
+
{{InformationCollapsed|1=Decorate a generic AI|2=The [https://en.wikipedia.org/wiki/Decorator_pattern decorator pattern] can be used to add flexibility to a generic AI. A decorator is a simple program to tell a bot what to do at the start of the map or in certain situations. Tags or conditions can activate or deactivate certain parts of the generic main AI. The different parts of the main AI are included as a sub AI.}}
  
=== Ultimate AI for beginners (16 nodes) ===
+
{{InformationCollapsed|1=Ignore tagging|2=New players can totally ignore tagging. (especially for combat) }}
  
PEW presented this [https://forum.gladiabots.com/viewtopic.php?f=3&t=647 Ultimate AI for beginners] in the forum.
+
{{InformationCollapsed|1=Start experimenting|2=Don't follow rules. Sometimes you have to break a rule to dominate. Some rules also have cons one should be wary about.}}
  
[[File:Ultimate AI for beginners.png|thumb|none|800px|Ultimate AI for beginners - [https://wiki.gladiabots.com/images/3/3c/Ultimate_AI_for_beginners.png Higher resolution (2236 × 1228 pixel)]]]
+
== Simple bots ==
  
The AI is split into this main modules:
+
''Main Page: [[Simple Example Bots]]''
  
* Blue: The retreat module
+
One can learn of bots with few nodes that have a pretty good performance in the game. They are a great base to start optimizing for beginners but also for advanced players to test their AI against.
* Yellow: The shooting module (with high priority)
+
* Green: The resource module
+
* Red: The pushing module
+
* Pink: The shooting module (with low priority)
+
 
+
=== Grand Master League Bot (30 nodes) ===
+
 
+
LuBeNo presented this [https://forum.gladiabots.com/viewtopic.php?f=3&t=605 Grand Master League Bot] in the forum.
+
 
+
[[File:Grand Master League Bot.png|thumb|none|800px|Ultimate AI for beginners - [https://wiki.gladiabots.com/images/7/7a/Grand_Master_League_Bot.png Higher resolution (2276 × 986 pixel)]]]
+
 
+
The AI is split into this modules:
+
 
+
* Defense
+
* Shotgun
+
* Offense
+
* Dancing
+
  
 
== Useful resources ==
 
== Useful resources ==
Line 92: Line 93:
 
There are several places to discover new strategies, learn tactics of other players or ask questions:
 
There are several places to discover new strategies, learn tactics of other players or ask questions:
  
* Check the [https://forum.gladiabots.com community forum]. Also "old" topics there can give nice information.
+
* Check the chat groups on [http://discord.gladiabots.com/ discord] and [http://telegram.gladiabots.com/ telegram].
** Especially the sections ''Strategies'' and ''Questions'' are interesting.
+
** For example check [https://forum.gladiabots.com/viewtopic.php?f=3&t=823 this topic about shared ideas how players approach the game]. Several strong players of the year 2017 contributed to it.
+
* Check the chat groups on [http://telegram.gladiabots.com/ telegram] and [http://discord.gladiabots.com/ discord].
+
 
* Check the wiki itself to learn about game mechanics and bot programming and their sub topics. There are several nifty details to discover.
 
* Check the wiki itself to learn about game mechanics and bot programming and their sub topics. There are several nifty details to discover.
 
* Check the [[changelog]] or [http://roadmap.gladiabots.com roadmap] to learn about recent or planned changes and adjust your AIs according to them.
 
* Check the [[changelog]] or [http://roadmap.gladiabots.com roadmap] to learn about recent or planned changes and adjust your AIs according to them.
  
 
Last but not least one should play the game. Especially lost games show flaws of the AI, that need to improved. Try to analyze the strategy your enemy used.
 
Last but not least one should play the game. Especially lost games show flaws of the AI, that need to improved. Try to analyze the strategy your enemy used.

Latest revision as of 18:55, 12 April 2021

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.

Information.png
Divide and conquer. 

Break down a problem into two or more sub-problems and solve each of them separately. Complex sub-problems can again be divided. In Gladiabots this could be done by creating sub-AIs for each sub-problem. The complexity is reduced leading to a better maintainability.

Information.png
Readability first. 

AIs are written once, but read many times. Overlapping nodes, links crossing each other and great distances between linked nodes are difficult to read and should be avoided. AIs should have meaningful names revealing their purpose. One should consider to align nodes to the grid.

Information.png
Don't repeat yourself. 

Avoid using the exact same set of nodes in several places. Sometimes duplicate nodes can be prevented by using bot specific filters or additional conditions. If its not possible to prevent duplicate nodes in the first place one can try to move them to sub AIs.

Information.png
Keep it simple. 

The size of an AI has a significant effect on the error rate. A simple solution should be preferred over a complex one leading to the same or very similar results. One should ask the question: "Has this AI been implemented with the least amount of nodes necessary?". The more complex the AI is the more likely it is to be buggy.

Information.png
Test, test, test. 

"If debugging is the process of removing bugs, then programming must be the process of putting them in." (Edsger Wybe Dijkstra) As no developer is perfect, new nodes should be tested and debugged right after they were added.

Micro or Macro

A macro strategy uses a few nodes to do a lot of things approximately, a micro strategy uses lots of nodes to do one thing well. You need both to be great. Try thinking how you can replace a small amount nodes with a more precise sub-AI, but when you have a new idea, try starting small and finding a good default.

Some players will naturally be better at one or the other. Remember that you can always find friends to help you out.

Ideas worth implementing

Retreat

Information.png
Retreat at shield level other than 0-25%. 

Retreat early when being attacked by several units at medium range. Don't wait until your shield is 0-25%, otherwise those enemy units attacking you at medium range will continue to attack you as you move into long range, which is something you want to avoid with such a low shield. If you're being attacked by a machine gun and a sniper at medium range then you'll probably want to retreat at all shield/health levels.

Information.png
Only retreat as long as someone is attacking. 

Don't retreat because your shield is low, but because someone attacks you. If no one attacks you anymore stop the retreat process.

Attack

Information.png
Minimize the time spend switching attack targets. 

Usually a bot should continuously attack the bot it started to attack. (by filtering a target attacked in the previous tick) Create strict rules for when to switch targets. For the sniper and machine gun, whose reload time is quite long, it's especially important.

Information.png
Focus fire. 

Prioritize enemies that are already being attacked by your allies or prioritize enemies with low shield.

Push

Information.png
Shoot medium range. 

Aggressively push to medium range. Little damage is done at long range, so pushing to medium maximizes your damage and also pushes your opponent, especially if you have many pushing at once. Careful, a bad push can be a big risk too.

Information.png
Push in the right moment. 

Don't push when being attacked. Sometimes the pushing process should be aborted, because too many enemies are around.

Information.png
Flank or circle bots. 

Flanked and circled bots get easily destroyed. Try to avoid pushing too aggressively, so you don't get caught between two enemies.

Collection

Information.png
Score wisely 

Try to score to bases away from the enemy, but not so far away that you spend valuable time carrying the resource there.

Information.png
Score unexpected 

Try to rush for early resources or smuggle resources mid game. Sometimes also picking 2 or 3 resources at once works.

Domination

Information.png
Go for bases 

You get points for bots being on bases, so any time spent outside bases is wasted time.

Information.png
Find the right force fields 

Not all force fields are equal, find the ones that cover multiple bases.

Elimination

Information.png
Know when to shoot 

The less you shoot, the more you push. It's often more important to know when to shoot than who to shoot.

Information.png
Work as a group 

Bots together cancel each other's weaknesses. Keep your bots together.

Shotgun

Information.png
Shoot at second sight 

The shotgun should not always start shooting at the first bot it sees at medium range. Its good to get as close as you can to medium range units, especially if they are retreating or being attacked by an ally. This will give your shotgun more medium range shots as the enemy unit tries to escape from medium range. For example only stop moving towards medium range units when at least 2 units are in medium range.

Sniper

Information.png
Focus on the enemy sniper 

Pay a lot of attention to your opponent's sniper. Your sniper should prioritize attacking the enemies sniper. If your sniper hits the opponent's sniper then it's probably worth changing the attack target of all your nearby units to it, even if they are attacking medium range units. (and only if it is safe/worthwhile doing so)

Machine Gun

Information.png
Hold your ground 

Machine guns are great at holding positions or bases.

Information.png
Carry resources 

Machine guns are the fastest bot to score resources (but not to grab).

General

Information.png
Think about maintainability 

Don't use to complicated structures, map and bot specific stuff. It's easier to make one generic AI then to handle a truckload of specialized ones.

Information.png
Decorate a generic AI 

The decorator pattern can be used to add flexibility to a generic AI. A decorator is a simple program to tell a bot what to do at the start of the map or in certain situations. Tags or conditions can activate or deactivate certain parts of the generic main AI. The different parts of the main AI are included as a sub AI.

Information.png
Ignore tagging 

New players can totally ignore tagging. (especially for combat)

Information.png
Start experimenting 

Don't follow rules. Sometimes you have to break a rule to dominate. Some rules also have cons one should be wary about.

Simple bots

Main Page: Simple Example Bots

One can learn of bots with few nodes that have a pretty good performance in the game. They are a great base to start optimizing for beginners but also for advanced players to test their AI against.

Useful resources

There are several places to discover new strategies, learn tactics of other players or ask questions:

  • Check the chat groups on discord and telegram.
  • Check the wiki itself to learn about game mechanics and bot programming and their sub topics. There are several nifty details to discover.
  • Check the changelog or roadmap to learn about recent or planned changes and adjust your AIs according to them.

Last but not least one should play the game. Especially lost games show flaws of the AI, that need to improved. Try to analyze the strategy your enemy used.