The latest Airships update fixes a bug in the combat AI for ships. It was a rather weird and stupid bug, and so I'd like to tell you about it. I hope to entertain you and also give you a view into the game development process.
There were a lot of reports of the combat AI being very incompetent when trying to attack buildings, especially from close range. Ships would just float around unmoving instead of closing in and bringing their weapons to bear.
So I set about reproducing this problem, which turned out to be rather easy. I set up a combat of an AI grenade bomber versus a building, and the bomber completely failed to position itself.
I will explain the cause of this in a moment, but I first have to get into the detail of how combat AI works. Its main function is to evaluate possible positions for the ship to move to. For each position, it looks at how much damage it can deal from there and how much enemy fire it's exposed to. Some positions it can't get to, because something's in the way, or because they're above its service ceiling.
The other mildly confusing thing I need to mention is how the y-axis in the game's coordinate system works. It points downwards, so ships with a higher y-coordinate value are further down. And the zero point is at about 70 metres above ground. Not the most sensible way of doing things, but it just evolved that way.
I have a convenient debug view in the game that lets me see the combat AI's evaluation of all the positions it considers. In the case of the combat of the bomber versus the building, I could instantly see that it marked all the positions near the ground as unreachable. All the positions with y-coordinate greater than zero.
At this point I had a pretty good idea of what was going on. The culprit was an obscure module type value called aiMaxY. This value is used to tell the monster AI to not move too far down, because it looks weird. For example, it prevents the Aerial Jelly, which is meant to hover above your ships and attack like that, from moving all the way to the ground.
aiMaxY is set to 10000 by default, going all the way into the ground. But by looking at the debugger, I could see that the bomber's aiMaxY was actually set to 0. So the AI considered all positions where y was greater than 0 as invalid.
Now I just needed to figure out why the value was at 0 instead of 10000.
The culprit there turned out to be flipped modules. The information for flipped versions of modules is derived automatically from their un-flipped counterpart. The game does this by copying all the information and adjusting it where needed, making firing arcs point the other way, mirroring the graphical appearance, and so on.
But I had forgotten one line in this code. It didn't copy over the aiMaxY value, and instead left it at 0.
So all flipped modules would tell the combat AI to not take the ship beyond y = 0. Any airship with a flipped module had broken AI. Which was many but not all of them, making the bug appear inconsistently.
The fix was painfully easy: add that line to copy over the aiMaxY value for the flipped module. And with that one change, the AI started behaving much better!
Airships: Conquer the Skies
David Stark
David Stark
2018-08-16
Action Indie Strategy Singleplayer Multiplayer
Game News Posts 306
🎹🖱️Keyboard + Mouse
Overwhelmingly Positive
(5250 reviews)
http://www.zarkonnen.com/airships/
https://store.steampowered.com/app/342560 
The Game includes VR Support
Airships Linux 53 [139.2 M]Airships Linux 64 [545.79 M]
Airships: Conquer the Skies - Soundtrack
Airships: Heroes and Villains
In the game, ships are viewed side-on, and their modules are operated by individual crew members. During combat, players give high-level commands to a small fleet, positioning their ships, ramming and boarding others. Ships and terrain are fully destructible: they can catch fire, explode, break apart, and fall. Players can also compete against one another in Internet and LAN matches.
The ships are highly detailed, teeming with sailors moving around at their individual tasks, like an ant farm or a cut-away drawing. The player's choices in ship layout are crucial, and an important part of the game is exploring the design space of different airships and their matching tactics.
- OS: Ubuntu/Debian/Mint
- Processor: 1.8 Ghz+Memory: 256 MB RAM
- Memory: 256 MB RAM
- Graphics: 1 GB VRAM+
- Storage: 1 GB available spaceAdditional Notes: Not currently compatible with Intel HD graphics controllers. May run on other Linux distros. but no guarantees.
- OS: Ubuntu/Debian/Mint
- Processor: 2.2Ghz+ Dual-coreMemory: 2 GB RAM
- Memory: 2 GB RAM
- Graphics: 2 GB VRAM+Network: Broadband Internet connection
- Storage: 1 GB available spaceAdditional Notes: Not currently compatible with Intel HD graphics controllers. May run on other Linux distros. but no guarantees.
[ 5166 ]
[ 1903 ]