More AI

MORE AI

AI Randomness

As you read in Room AI 1, if an action is targeting a room type, and there are multiple of those rooms on the opponent’s ship, the AI will choose a random one. However, the choice is the same for all rooms that choose in the same frame. This means if you have all of your lasers and missiles use “none, target reactor” then they will all evaluate their AI in the first frame, and shoot the same reactor at the start of the battle. In the first frame after that first reactor is destroyed, they will all pick a new reactor, and all of them will shoot that second reactor together. This will continue until all reactors are destroyed. The only time your guns may shoot different rooms is when the gun has a volley length – it only retargets at the end of the volley. If the room it’s shooting dies during the volley, the other rooms will pick a new target that instant, but the shooting room will pick a room at the end of the volley. See Room AI Tricks “micro delay” for ways to choose different rooms of the same type.

For crew, this works a little differently. Crew choosing a room on your ship will choose the closest room of the specified type. Crew choosing a room on the opponent’s ship, while still on your ship, will choose a random one of that type (because the teleport distance is equivalent to all rooms). Once on the opponent’s ship, your crew will walk to the closest room of that type. For example, if you have “none, target enemy reactors”, your crew will run to your teleport and port into a random reactor. Your first three crew will all pick the same reactor. Once they destroy that reactor, they will run to the closest one, and continue from there until the crew dies or all the reactors are destroyed. 

AI doesn’t want to change

If a targeting command is true and valid, AND the room is already targeting a room that satisfies the command, the room will not switch targets. Usually, this means a room will keep shooting a room until it dies, but it can lead to some strange behavior. Say you have a laser with just three commands:

1) None – Increase power by one 
2) Target room has enemy – Target random enemy room 
3) None – Target enemy reactor

What happens if you’re shooting reactor1, and an enemy walks into that room, making command two true? The laser will keep shooting reactor1, because command two is already satisfied – the laser is targeting a valid “random” room on the enemy ship that has HP. This situation would be the same if command two was “target room has enemy – target enemy reactor”. 

Continue Current Job

Python 3 is a core AI research that you can get at level 9 and laboratory level 8. It adds some key commands around crew detection, namely the conditions “friendly room has enemy” and “target room has enemy”. These are self-explanatory, but the action “continue current job” is not; it is worth a little explanation on its own.

Continue current job (CCJ) is an action that is like a hold command; it executes whatever the last valid action was. You can think of the action as “keep doing whatever you were doing.” At the start of the battle, CCJ for crew will make them stay in their current room, and for rooms it will make them not shoot any room, though their reload bar will fill up. For both crew and rooms, CCJ only applies to targeting actions. It doesn’t affect power usage, ability usage, or ammo selection.

Let’s look at an example for our MSL: 

1) None – Increase power by one 
2) None – Set cheapest items 
3) Target room destroyed – continue current job
4) None – target enemy reactor

*Target room destroyed is currently not working correctly on iOS, but is working on Android. The example still holds, this is how things should work.*
In the first frame, our AI runs and tried to find a valid and true targeting command. Command 3 is not true because the target room is not destroyed (I think there is a phantom room all weapons start out targeting when the battle starts. Anyways, it doesn’t count as destroyed). Command 4 is valid, so the MSL starts shooting a random reactor (call it reactor1). 

In the first frame after reactor1 is destroyed, command 3 is true and valid. The condition in command 3 is true because the targeted room (reactor1) is destroyed; and the CCJ action is always valid. So, the AI will choose command 3 as the targeting command for this frame, and the MSL will keep shooting reactor1. 

In any frame after this in which reactor1 has been repaired, command 4 will go back to being the first true and valid targeting command. However, since reactor1 already satisfies command 4, the AI will not retarget and will keep shooting it (see AI doesn’t want to change higher on this page). 

Once reactor1 is destroyed again, command 3 will be true and valid. The end result is that the MSL will keep shooting reactor1 throughout the entire battle. 

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top