Seems reasonable. However, this method also leads to a hit to the ship being able to damage cells across a gap in the ship (e.g. imagine a ship that consists of two parallel lines of armor cells 1 cell width apart, then with this algorithm hits on either line will also damage the other). Is that how it works?
Also, another case, does that mean that for a ship shaped like a triangle, the armor grid is shaped like a stepped pyramid, with hittable armor cells everywhere where at least 1 pixel of the triangle exceeds a grid boundary? Alternative version: say that somebody has specified a ship that is exactly 1 armor cell wide and 1 armor cell + 2 pixels long. Does this ship have 1, 2 or 3 hittable armor cells? For example if the logic is center the ship on a grid of square armor cells, then add hittable armor cells to all squares where the ship has a nonzero area, then this would have 3 armor cells with shots parallel to ship length hitting different cells depending on direction and shots parallel to ship width hitting mostly one cell. And another: say that someone has made a ship that is square and the size of 1 armor cell, but rotated it 45 degrees so it is oriented like a diamond. Does this ship have 5 different hittable armor cells?
The algorithm for shields is
1. At the start of each second, compute incoming damage
2. Then if you can block without overloading, do so, and deal all damage that second to shields, otherwise to armor
3. If you did not block, dissipate first soft and then hard flux equal to flux dissip stat. If you did, soft flux only and equal to flux dissip - shield upkeep.
There is still the question of what to do with ships with different dps optimum angles vs shield and armor. One step at a time I guess. There are broadly four different strategies: 1. ignore, 2. assume ship always uses optimum (can rotate instantly), 3. compute some kind of an index beforehand to determine which to use for the whole combat (optimal rotation when unable to rotate), 4. rotate the ship based on some kind of a threshold with the rotation taking actual time (pseudo-ai).
It occurs to me that there is a terrifying possibility that is permitted by options 3 and 4: what if the optimum angles are angles that are neither the highest dps vs enemy shields nor the highest vs armor?. For example imagine a ship that rotates extremely slowly and has a fixed gun that deals 399 energy dps straight ahead, and two other fixed guns, one dealing 200 kinetic dps to the exact left and one dealing 200 he dps to the exact right. It seems like the correct choice for this ship would be to not rotate at all using options 3-4, but we would not find this choice using the dps at angles function we have now, just checking dps vs shields and dps vs armor...
I suppose we would find this maximum by computing an "average real dps vs shields and armor" which would be something like shield dps*shield efficacy - shield regen vs shields and the solution f'(1) to f'(t)=dps*hit strength/(hit strength+armor -f(t)) vs armor and then maximize the average of those two, possibly weighed with something.
At this point it might be helpful to know how the game's AI makes that decision. Because it probably doesn't involve solving this but rather something like "point biggest gun at target". If we knew that we could just replicate the process since that is the most valid way to do it even if it doesn't lead to mathematically optimal damage.