Fire Sustain Guide

From Gladiabots Wiki
Jump to: navigation, search

The Problem

A classic problem in Gladiabots is bots switching targets mid-shot and never getting a shot off. Let's start with a very simple combat AI.

A very simple AI

As you can see, the attack command executed is to just always attack the closest enemy in range. What often happens with this attack is that another enemy walks in closer while you are aiming, causing you to switch to this new target, before having fired a shot. This is almost always a bad idea, but how can we remedy this?

Keep attacking

The first thing we can do is just simply keep attacking any target we're attacking. The game explains this mechanic in the Advanced Training tutorial "Pursue Current Target". I suggest that you redo this tutorial before continuing to read this guide, because it nicely illustrates another problem you can have without a good fire sustain.

Attack the closest bot in range, attacked by me

Let's add this node to our simple AI. It should precede any other attack nodes and always have the highest priority, so that our bots can no longer switch targets while attacking.

A simple AI with sustain node

The Simple Shotclock

The more advanced version of controlling fire sustain is to use a shotclock. We use a counter to keep track how long a bot has been firing, so we continue the shot until the moment just after a shot was fired. This allows the bot to retarget whenever it wants, but without canceling its shot.

If you want to make the simplest shotclock there is, you can simply make sure that no shoot nodes are allowed to retarget. Put these in front of your attack module and you'll get a serviceable shotclock. They use the simplified model where Assault shoots for 5, Shotgun shoots for 5, Sniper shoots for 13 and Machine Gun shoots for 38. These timings tend to be "close enough" for most real-world AIs.

Shotclock-simple.png

Refining

Now we can start refining the shotclock. One big issue with shotclocks is that bots will have to sustain for 1 turn longer than their aim length, because the shot is fired on the turn after it finishes aiming. If we look at the Sniper, for example, this means that it has to sustain for 13 ticks, even though it aims for 12. If we keep aiming at the same enemy however, the second shot fires after two aim cycles, plus that 1 turn, aka 25 ticks, not 26. This means that the length of the shot cycle for a sniper is 12N + 1, where N is the amount of shots fired. To keep track of this, we use a tag, so that we know if this is the first cycle we're firing at an enemy (add 1) or a subsequent cycle (don't add 1, we already added the 1 in the first cycle).

Shotclock-specialized.png

For the Machine Gun, I went a little fancy, it will sustain its shot until it matches the Assault Bot in terms of DPS and then allow you to retarget. Picking a lower cutoff like this allows the Machine Gun to put more pressure forwards, play around with it!

The Perfect Shotclock

Now, you might be wondering: can't we just count the shotclock at the start of our AI, using a sub-AI, so I can just throw that into whatever AI I'm creating? Sure! Here's an example of what that would look like:

Shotclock-gilberreke.png

Note that you would take out the two nodes on the right and move those into your attack sub-AI and put the rest of this AI early on in your AI before any potential actions are taken.