BrokenRegistry / Rotp-Fusion

Other
22 stars 4 forks source link

Don't send transports that will be shot down #11

Closed dHannasch closed 1 year ago

dHannasch commented 1 year ago

The only behavioral change this makes is that autotransport will not send transports when there is currently an enemy fleet orbiting the destination that will shoot the transports down.

If there is an unarmed scout parked over the planet, autotransport will still send transports normally. (...I just now realize that I'm not really sure why the AI likes to park unarmed scouts over enemy planets, but anyway, autotransport will ignore them.)

This introduces a bunch of machinery that it doesn't really take advantage of, because it's not doing anything very smart: it ignores the transports' travel time to the destination and ignores any enemy fleets that might be visibly en route. That kind of logic gets complicated fast, because you might, for example, build warships before the enemy fleets arrive. So I haven't made it do anything like that, but the "firewalled" estimatedFleetDamagePerRoundToArrivingTransports() using only information available to the empire means we could do something like that.

For ships already in orbit, you get a free scan anyway, but for ships en route, we have to be very careful about what information is available to the empire at the time. estimatedFleetDamagePerRoundToArrivingTransports() does that.

It seems reasonably safe to assume that if there is currently a blockade, transports should not be sent, especially since (within a given single year) friendly transports are assumed to arrive (and get shot down) before friendly relief fleets. (Though even for this, for long transport-trips there can be exceptions.)

This also deduplicates the firepower sum for arriving transports within Colony, but it doesn't deduplicate between the firepower sum over real ships (the real sum, in Colony) and the firepower sum over ShipViews (used only for making decisions). It would be nice to have those using common utility functions since the same conditionals should always apply to both (e.g. when modnar made only anti-ship firepower apply to transports, any change like that should apply equally to both), but I haven't figured out how to make that happen. As you can see, there's still a lot of duplicated code in this.

BrokenRegistry commented 1 year ago

It seems reasonably safe to assume that if there is currently a blockade, transports should not be sent, especially since (within a given single year) friendly transports are assumed to arrive (and get shot down) before friendly relief fleets. (Though even for this, for long transport-trips there can be exceptions.)

Totally agree with that!

And yes, duplicate code is quite anoying... When you change a standardized call to a parameter, you always need to check for remaining direct calls to this parameter!