Request: increased air ranges and ship movement

Moderator: Hubert Cater

Post Reply
User avatar
Elessar2
Posts: 1454
Joined: Wed Nov 30, 2016 12:35 am

Request: increased air ranges and ship movement

Post by Elessar2 »

Appreciate it if all air ranges could be capped at 50 and not the current 25. Same with ship movement. Yes, this is for my huge Euro scenario where the existing caps are too small for my scale. [And yes request is for both SC WWII titles]
User avatar
Hubert Cater
Posts: 6023
Joined: Mon Jul 22, 2013 11:42 am
Contact:

Re: Request: increased air ranges and ship movement

Post by Hubert Cater »

Hi Elessar,

It's on my list but unfortunately I cannot guarantee it might ever see the light of day, e.g. things become a bit problematic once the map sizes get too big and the ranges too high as it really slows things down. It's an issue I've not been able to work around just yet.

Hubert
The Land
Posts: 940
Joined: Fri Feb 19, 2010 4:58 pm

Re: Request: increased air ranges and ship movement

Post by The Land »

Hubert Cater wrote: Wed Nov 30, 2022 2:14 pm Hi Elessar,

It's on my list but unfortunately I cannot guarantee it might ever see the light of day, e.g. things become a bit problematic once the map sizes get too big and the ranges too high as it really slows things down. It's an issue I've not been able to work around just yet.

Hubert
Elessar - you can increase air ranges a fair bit by having a tech that adds +25 per level. I think there might be a genuine hard cap in there somewhere though. And my attempts to model B-52s and Backfires with 75-hex range just result in it taking 20 seconds to select a unit.

I get the feeling it's something about the engine having to locate every hex within move range and calculate valid destinations, which gets ludicrous at high ranges.
1985 Red Storm mod - Beta testing!

Always wanted to play a "Cold War goes hot" scenario? Come and join in!
User avatar
Elessar2
Posts: 1454
Joined: Wed Nov 30, 2016 12:35 am

Re: Request: increased air ranges and ship movement

Post by Elessar2 »

Yeah way ahead of ya on using tech to increase the ranges. I'd likely have to cap the max level @ 4 tho to compensate.

Your comment is a bit worrisome Hubert: I am well aware that a beefy rig will likely be needed for my magnum opus (note I will be bugging Santa for a new one)-is there something in the code or yes the optimization routines which will cause things to grind to a halt if the maps get too big and/or detailed, as The Land outlined? I may have to craft a quick and dirty scenario in a finished area of the map just to see how things run. This also means that I may have to dial back some of my detail (minor rivers and small towns and such), and leave places like Greenland and N Canada with no terrain.
User avatar
Hubert Cater
Posts: 6023
Joined: Mon Jul 22, 2013 11:42 am
Contact:

Re: Request: increased air ranges and ship movement

Post by Hubert Cater »

It's just a function of the number of hexes and how long it takes to solve path finding and target calculations, and no matter what type of setup you have, you eventually reach a point where there can be such a large amount of growth in the algorithms, that the calculations become expensive and time consuming, e.g. even on the fastest PCs, you'll notice a slow down as the calculations become essentially quite massive.

For example, and starting with map sizes, if we look at the War in Europe map, it is 268x138 hexes, which works out to approximately 37K hexes.

If we opt for the maximum size of 512x256, that works out to approximately 130K hexes.

Now let's say you want to path find from one end of the map (worst case), to the other end of the map, and even disregarding that no unit can reach from one end of the map to the other end of the map, the entire path needs to be calculated to know the optimal path even for the shorter range. But I can optimize things to be less accurate after the immediate range of the unit, so lower ranges of movement, targeting etc., can help speed things up.

Path finding involves essentially having a graph algorithm to figure out the shortest and most optimal path, and right now the game uses the most optimal one known which is A*. And sometimes in combination with pre processed graphs, but this is not always possible as path availability can change during game play, e.g. neutral countries come and go into play, some positions can get blocked or unblocked, e.g. Gibraltar etc.

For reference this is A*:
https://www.geeksforgeeks.org/a-search-algorithm/

For ranges, you are looking at the following formula:

# of hexes = 3*n*(n+1)

e.g. a range of 1 hex will give you 6 hexes total, range of 2 will give you 18 hexes total and so on.

Max range is 25 which works out to about 1950 hexes for the game to consider, and a jump to a range of 50 works out to 7650 hexes.

1950 hexes is already quite a bit, and the game has to consider all targets whenever you click on a unit with that range within the 1950 hexes, e.g. pre-calculate all possible targets, and all possible combat results and so on.

Unfortunately these things just take time, thus the current caps to keep the game play to a reasonable speed feel overall.
User avatar
Elessar2
Posts: 1454
Joined: Wed Nov 30, 2016 12:35 am

Re: Request: increased air ranges and ship movement

Post by Elessar2 »

That was very illuminating HC. Whatever you can do on your end would be appreciated. I am guessing that map detail and all of the various layers are not nearly as taxing on the game & hardware in comparison.
User avatar
Hubert Cater
Posts: 6023
Joined: Mon Jul 22, 2013 11:42 am
Contact:

Re: Request: increased air ranges and ship movement

Post by Hubert Cater »

The various layers are not as taxing as the game only renders to screen what you can currently see, e.g. outside of the map display area, it is not drawn, so this speeds things up. Scrolling is optimized as well by shifting the visual contents and only drawing the new hexes, e.g. scroll to the right and the visual contents are shifted left with only the last two hexes drawn on the right edge, as an example.

But when it comes to the logic of the game and specifically path finding, the whole map is considered, just because it has to be, even with many optimizations I've put into place, like pre-calculating what is considered connected and accessible and so on. For that, for now, unless some new algorithms come into existence, there is not much I can do, unfortunately.
User avatar
Beriand
Posts: 320
Joined: Mon Aug 16, 2021 2:33 pm

Re: Request: increased air ranges and ship movement

Post by Beriand »

I also encountered this problem before, so small comment... sorry if it is completely wrong, as for me it is obviously guessing game without look into mechanisms :oops:

When I make ships with 50 action points, so 50 movement points, selecting them are not a (big) problem. Even in cruise mode, with 100 hexes range. So apparently pathing alone works alright for our needs?
Ok, but bigger problems are strike range of planes. Even at, like, 35, it is slower than movement of 100, more than a second to select a plane. At least for me. And strike range 50 is like 4x slower than 35. But why? :geek: Especially if pathing is not a problem. And even if there are 0 enemy fighters and anti-air units, which could complicate things.
Hubert Cater wrote: Thu Dec 01, 2022 2:42 pm and the game has to consider all targets whenever you click on a unit with that range within the 1950 hexes, e.g. pre-calculate all possible targets, and all possible combat results and so on.
Well my only guess at this point would be these combat result predictions, as mentioned, since I'm not sure what would be other difference between 'movement and strike', as pathing and drawing seems to work in acceptable time, and there are 0 anti-air or fighters which could influence the result of tests. Strange thing is that selecting a plane takes roughly the same time on zoom level 1 and zoom level 2... and there is a big difference in selecting planes with range 35/50, even while map is less than 35 hexes in radius, so what we see on the map is literally the same in both 35/50 cases. As pathing apparently works quickly enough, then my blind guess would be that this combat result predictions (or something else) is resolved all the time for the whole range, not only for the hexes currently visible on the map?
Maybe it could be somehow changed, as drawing with the scrolling? And if not, most of the combat predictions are "?:?", as usually we do not have vision on most of the enemy hexes; then if indeed resolving combat takes so much time (I do not know), maybe it could be done only for hexes with vision? Just guessing, sorry.
User avatar
Hubert Cater
Posts: 6023
Joined: Mon Jul 22, 2013 11:42 am
Contact:

Re: Request: increased air ranges and ship movement

Post by Hubert Cater »

To clarify, selecting a unit in single player mode does not do any path finding calculations, e.g. path finding calculations to go from A to B for the AI is an algorithmic calculation that just takes time, and especially so when ranges and map sizes increase.

When a player selects a unit, you select your own path and that is pretty straightforward and there is no expensive calculations being performed there. The only calculation is the movement range calculation, e.g. outward range from a unit, and that is then the pre-calculated graph, in other words when you select a hex to move to from the movement range, it is quick as the graph is already set when you pick to go from A to B.

For the AI, it doesn't know how to go from A to B, it doesn't know all the options and what the most optimal path will be, thus the A* algorithm.

Here is an animation to give you an idea:
https://www.youtube.com/watch?time_cont ... e=emb_logo

Clicking on units with very high range will potentially slow things down, e.g. a range of 50 is over 7K hexes to consider, and one way to speed that up in single player, if you want that high of a range, is to disable the 'estimated losses highlights' and 'enemy target highlights' in the OPTIONS->ADVANCED screen.
User avatar
Beriand
Posts: 320
Joined: Mon Aug 16, 2021 2:33 pm

Re: Request: increased air ranges and ship movement

Post by Beriand »

Thanks for the answer :) Yes, by pathing I mean computing the graph, 'movement range calculation'. I assume it is also computed when I select a unit, as hexes in range are highlighted etc. In general, the number of hexes and graphs we consider are very small, even for range 100 it is 30300 hexes. With millions of arithmetic operations in under a second, handling just this computation is super fast, which is why I assume there are other things that takes time, like combat predictions, drawing, or accessing stuff sitting in hexes.

Ok, so when I disable 'estimated losses highlights' and 'enemy target highlights', it speeds up things by around 30%. Which probably means that drawing things have some contribution to the problem, hm, strange (as choosing 50 AP ship highlights much more hexes while working much faster, but then maybe drawing "?:?" is more complex than highlighting a hex). But also drawing is not the only slowing factor anyway.
Basically what I stated is that it is quite unclear what is being computed outside of 'visibility zone' of zoom level 1 besides adjacency/range graph. And graph works quickly enough, so there are additional things being computed for hexes outside of the displayed map. To put it other way, I have 'width' of 26 hexes on zoom 1, but selecting a plane with strike range 50 takes ten times longer than a plane with strike range 25 (despite 'showing me the same'), and it is probably not because anything connected to paths. But yeah, that is just a comment, so ;)
Chernobyl
Posts: 640
Joined: Mon Aug 27, 2012 5:51 am

Re: Request: increased air ranges and ship movement

Post by Chernobyl »

A simple solution for air pathing might be to allow planes to fly over neutral airspace. Not sure if this is more or less historical as certainly it was done sometimes and avoided other times.
User avatar
Hubert Cater
Posts: 6023
Joined: Mon Jul 22, 2013 11:42 am
Contact:

Re: Request: increased air ranges and ship movement

Post by Hubert Cater »

There are times where a less than optimal set up on my end is not exposed until the extreme cases, and after looking at high AP and high SR units in a quick test I could see that some of the routines handling things like setting up the estimated target highlights and estimated losses highlights, as well as how it sets up the strike range calculation and the unit movement range calculations could have been improved.

I've made some tweaks and there is a noticeable difference and this will be updated in the next patch.

However, there is only so much I can improve since as mentioned, while the general range calculations can be fast enough, iterating through the data structures, the checks on valid adjacent hexes, look ups on the units, resources, terrain, roads etc., from the game map as well as a whole list of other factors just slow things down the greater the ranges increase.

For example, attacks from some hexes are better than other hexes and multiple calculations need to be done, checked and verified against, air unit attacks can have interceptors, escorts, and the game cycles through to find the most optimal ones, and ranges need to be checked and so on. On an air unit with a strike range of 50 hexes you could easily have 500 targets, and any multiple combinations of interceptors and escorts that also have long ranges all have to be quickly factored in when just selecting the unit on the map.

Other elements are pre-calculated when you select a unit, such as can it be operated, reinforced, upgraded, transported and so on, and these take a brief amount of time to calculate as well.
User avatar
Hubert Cater
Posts: 6023
Joined: Mon Jul 22, 2013 11:42 am
Contact:

Re: Request: increased air ranges and ship movement

Post by Hubert Cater »

Chernobyl wrote: Tue Dec 06, 2022 12:53 pm A simple solution for air pathing might be to allow planes to fly over neutral airspace. Not sure if this is more or less historical as certainly it was done sometimes and avoided other times.
That one takes a bit of extra time too, as multiple paths sometimes need to be re-checked due to neutral air space.
User avatar
Elessar2
Posts: 1454
Joined: Wed Nov 30, 2016 12:35 am

Re: Request: increased air ranges and ship movement

Post by Elessar2 »

Adding en-route interception would presumably add to the given load there too.
Chernobyl
Posts: 640
Joined: Mon Aug 27, 2012 5:51 am

Re: Request: increased air ranges and ship movement

Post by Chernobyl »

Hubert Cater wrote: Wed Dec 07, 2022 5:31 pm
Chernobyl wrote: Tue Dec 06, 2022 12:53 pm A simple solution for air pathing might be to allow planes to fly over neutral airspace. Not sure if this is more or less historical as certainly it was done sometimes and avoided other times.
That one takes a bit of extra time too, as multiple paths sometimes need to be re-checked due to neutral air space.
I guess I don't understand. In my conception, remove neutral airspace except prohibit those hexes as final destinations (landing spots). No need to calculate any path at all. You either have the range to a valid destination hex or you don't.
User avatar
Hubert Cater
Posts: 6023
Joined: Mon Jul 22, 2013 11:42 am
Contact:

Re: Request: increased air ranges and ship movement

Post by Hubert Cater »

The issue with neutral airspaces is whether we allow flying over them or not, e.g. if we allow flying over them then yes prohibiting those hexes as final destinations is simple enough, but in game we don't allow flying over neutral airspace, so we need to calcluate (when applicable) flying around them which introduces some pathing calculations for air units, whereas otherwise no pathing calcuations are ever needed as it is just 'can it reach from A to B' etc.
Post Reply

Return to “Strategic Command WWII: World at War”