Supply Revisions

World in Flames is the computer version of Australian Design Group classic board game. World In Flames is a highly detailed game covering the both Europe and Pacific Theaters of Operations during World War II. If you want grand strategy this game is for you.

Moderator: Shannon V. OKeets

Shannon V. OKeets
Posts: 22165
Joined: Wed May 18, 2005 11:51 pm
Location: Honolulu, Hawaii
Contact:

RE: Supply Revisions

Post by Shannon V. OKeets »

ORIGINAL: Froonp

Maybe it was said below, but an idea to save time in calculating supply, would be to have units stacked with another non hq unit from the same country to use the same supply path as that unit.
Yes. Thanks.

There are several ways to do that. I'll choose one of them.

However, each unit will have its own copy of the path stored with the unit's information. That's so if the unit moves I do not have to worry about others units which had the 'same' supply path.
Steve

Perfection is an elusive goal.
User avatar
sajbalk
Posts: 264
Joined: Mon Jul 11, 2005 1:39 am
Location: Davenport, Iowa

WIfCon 2010

Post by sajbalk »

Hello All

WiFCon 2010 is this August in Lansing, Michigan, USA. I would encourage everyone to attend or at least visit the website at wifcon.org.

Hope to see you there.

Steve Balk
Iowa, USA
Incy
Posts: 336
Joined: Sat Oct 25, 2003 4:12 am

RE: WIfCon 2010

Post by Incy »

I have a proposal for the unlimited supply determination algorithm.

Instead of trying to trace paths, you could tray to trace a 'bag' and check if something is inside or outside the bag.
The bag could be centered either on the unit being tested, or on a primary supply source. I suspect the latter is better and will assume this.

To construct the bag you would start on a random primary supply source and trace a straight line in a random direction (disregarding supply cost, rail, etc) until you can't trace supply any further, this is an edge hex/Seazone. Then you recursively find all adjacent hexes that are also on the edge of your supply capability. Continue until the edge forms a full circle.

You'll also have to check for the two special cases that there is a separate bag inside of or outside of the current bag. This is easily done by checking if you can trace to all other primary sources from your starting source. You might also want to construct 'sub-bags' for parts of paths that are overseas, to solve some difficulties calculating edges when seazones are involved.

Once you have the bag in place (or several bags), determining unlimited supply becomes a matter of detecting if a unit is inside a bag or not. All units outside of a bag are unlimited OOS. Hopefully you have a good way of determining this.

Also, you could store the path of the edge around the bag just as you do with unit supply paths. This will allow you to detect potential changes in the shape of bag, and make a delta calculation everytime a bag changes.

Also, if you calculate bags, you can safely tag all units outside a bag as OOS, and you'll never have to recalculate them (until the a bag expands to put them back in unlimited supply).
Shannon V. OKeets
Posts: 22165
Joined: Wed May 18, 2005 11:51 pm
Location: Honolulu, Hawaii
Contact:

RE: WIfCon 2010

Post by Shannon V. OKeets »

ORIGINAL: Incy

I have a proposal for the unlimited supply determination algorithm.

Instead of trying to trace paths, you could tray to trace a 'bag' and check if something is inside or outside the bag.
The bag could be centered either on the unit being tested, or on a primary supply source. I suspect the latter is better and will assume this.

To construct the bag you would start on a random primary supply source and trace a straight line in a random direction (disregarding supply cost, rail, etc) until you can't trace supply any further, this is an edge hex/Seazone. Then you recursively find all adjacent hexes that are also on the edge of your supply capability. Continue until the edge forms a full circle.

You'll also have to check for the two special cases that there is a separate bag inside of or outside of the current bag. This is easily done by checking if you can trace to all other primary sources from your starting source. You might also want to construct 'sub-bags' for parts of paths that are overseas, to solve some difficulties calculating edges when seazones are involved.

Once you have the bag in place (or several bags), determining unlimited supply becomes a matter of detecting if a unit is inside a bag or not. All units outside of a bag are unlimited OOS. Hopefully you have a good way of determining this.

Also, you could store the path of the edge around the bag just as you do with unit supply paths. This will allow you to detect potential changes in the shape of bag, and make a delta calculation everytime a bag changes.

Also, if you calculate bags, you can safely tag all units outside a bag as OOS, and you'll never have to recalculate them (until the a bag expands to put them back in unlimited supply).
Nice in theory, but for the US, all of the US & Canada would be in one bag. And for the USSR it would include all of Siberia. One problem is that supply is different not only for each major power, but also for each minor country. That's a lot of bags to keep up-to-date.[:(]
Steve

Perfection is an elusive goal.
User avatar
Anendrue
Posts: 817
Joined: Fri Jul 08, 2005 3:26 pm

RE: WIfCon 2010

Post by Anendrue »

What if you used both methods. A bag based on primary sources for each country. Which could eliminate a lot of units needing to trace individual supply. Then check the few remaining units that are still not supplied.It might speed up the process or might not.
Integrity is what you do when nobody is watching.
Incy
Posts: 336
Joined: Sat Oct 25, 2003 4:12 am

RE: WIfCon 2010

Post by Incy »

I think large bag size is not a problem, I think it's an advantage. The larger the bag, the more you earn by only computing the edge (and not every possible path within the bag).

The america, siberia and africa bags would normally not change much during a game, most of the edge would remain static. The west and east edges of siberia, and the north edge of africa would see some adjustments, but for the main part they'd simply hug coast/boarder along the same path the entire game. Delta calculation of edges would not be very difficult to implement either.

The biggest gain would be that you never have to recalculate supply for anything outside of a bag.
You'd also never have to recalculate unlimited OOS status for any unit (which is probably an expensive calculation, that might have to be repeated very often, depending on your algorithm). All that is needed if you implement bags is to toggle a units 'unlimted OOS status' whenever it passes over the edge, or the egde passes over it.

I agree that it wil be somewhat complex to code (probably many days), so if you are able to solve well both
-unlimited OOS calculations
-calculating when units are brough back in supply
then you definately shouldn't consider this idea.


PS: You can eliminate the need for bags 'per minor' by calculating one bag that everyone on a side can use, and then add sub-bags for those parts only acsessible by some countries on a side. If/when the need arises I'll be happy to write out a more detailed algoritm for this.
Shannon V. OKeets
Posts: 22165
Joined: Wed May 18, 2005 11:51 pm
Location: Honolulu, Hawaii
Contact:

RE: WIfCon 2010

Post by Shannon V. OKeets »

ORIGINAL: Incy

I think large bag size is not a problem, I think it's an advantage. The larger the bag, the more you earn by only computing the edge (and not every possible path within the bag).

The america, siberia and africa bags would normally not change much during a game, most of the edge would remain static. The west and east edges of siberia, and the north edge of africa would see some adjustments, but for the main part they'd simply hug coast/boarder along the same path the entire game. Delta calculation of edges would not be very difficult to implement either.

The biggest gain would be that you never have to recalculate supply for anything outside of a bag.
You'd also never have to recalculate unlimited OOS status for any unit (which is probably an expensive calculation, that might have to be repeated very often, depending on your algorithm). All that is needed if you implement bags is to toggle a units 'unlimted OOS status' whenever it passes over the edge, or the egde passes over it.

I agree that it wil be somewhat complex to code (probably many days), so if you are able to solve well both
-unlimited OOS calculations
-calculating when units are brough back in supply
then you definately shouldn't consider this idea.


PS: You can eliminate the need for bags 'per minor' by calculating one bag that everyone on a side can use, and then add sub-bags for those parts only acsessible by some countries on a side. If/when the need arises I'll be happy to write out a more detailed algoritm for this.
I think there are too many intricacies in the supply rules for this to work. Here are a couple of the anomalies that supply has to deal with:

AOI unit - has 3 home countries.
Ski units - can ignore enemy zones of control.
Weather - changes the number of basic path hexes in a supply line (so the bags would have to be recalculated every time the weather changes); it also affects whether a port is iced in or not.
Optional rules - change how supply is calculated through sea areas.
Control of a sea area - affects supply through a straits hex.
Control of a city - has to be continuous for the entire turn for it to be a supply source
HQs can becomes primary supply sources - for a turn or for an impulse depending on optional rules
DOWs - affect which countries cooperate, which affects supply dramatically
Tertiary supply source - (secondary that can not trace to a primary but can trace to a secondary that is in supply) have to be determined within a'while' loop (or recursively, if you prefer).

That list is just off the top of my head, there are probably several more that I don't remember at the moment.

Whenever supply needs to be determined (which is continuously during land movment), the supply determination system hads to accommodate all those quirky rules. Add to the top of that Internet play, when multiple players on a side can be moving units simulataneously and affecting supply for both enemy and friendly units.

===
There's a good reason that the the new supply routines are 2650 + 1750 + 2350 + 975 = 7725 lines of code. And I haven't completed them yet. Somewhere around 9,000 to 10,000 lines of code is a likely final number. The basic algorithm isn't that hard to code, but all the odd bits take a lot of checking.
Steve

Perfection is an elusive goal.
User avatar
Anendrue
Posts: 817
Joined: Fri Jul 08, 2005 3:26 pm

RE: WIfCon 2010

Post by Anendrue »

ORIGINAL: Shannon V. OKeets
... all the odd bits take a lot of checking.
I am a little off topic here.
In my opinion, that is the main issue of programming a game like WiF vs creating a simpler game like Strategic Commnad. Im SC you just eliminate or not use what is difficult. In MWiF the overwhelmining majority of those odd bits must still be included or it is no longer the game you started to prorgram.

Now back to the topic.
I understand not using a reverse spread of supply (bag theory) now. So I'll just bag my comments and go...[:D] (it's ok to groan, my jokes are very bad indeed)
Integrity is what you do when nobody is watching.
Incy
Posts: 336
Joined: Sat Oct 25, 2003 4:12 am

RE: WIfCon 2010

Post by Incy »

Weather - changes the number of basic path hexes in a supply line (so the bags would have to be recalculated every time the weather changes); it also affects whether a port is iced in or not

I think you misunderstand the proposal somewhat.

bags are intended to find the edge of what can be supplied by unlimited supply. Everyting not inside a bag is completely isolated.
Calculation of bags would not be affected by weather, rail, etc.

Bags would not need recalculation becuase of changing sea supply (use sub-bags that can be connected/disconnected to the primary bags whenever tracing overseas).
Ski troops would need to be checked even if outside a bag.
Disappearing primary: check if last in bag. If so, remove bag.
Appearing primary: check if inside existing bag. If not, create bag
Multiple states of war: handled with sub-bags as described above (Ex: Italian ZOC -> create connected sub-bag tagged 'peace_required_with<Italy>')
tertiary: not relevant
Incy
Posts: 336
Joined: Sat Oct 25, 2003 4:12 am

RE: WIfCon 2010

Post by Incy »

I'm proably starting to be annoying on this, so don't waste your time adressing this now.

Just remember the concept for later use if you run into trouble with unlimited supply/ or excessive time use by constant reconnect attempts for supply paths
If that happens, send me an email and I'll happily work with you on the details

btw, bags can probably be a quite useful concept for the AI too, but let's not go there yet.
brian brian
Posts: 3191
Joined: Wed Nov 16, 2005 6:39 pm

RE: WIfCon 2010

Post by brian brian »

I noticed an obscure thing for the soon to be new supply routines do properly. Will they trace supply across frozen lake hexsides? They become river hexsides in winter. Then there are those extra tricky lakes that lay on weather boundaries.... just a thought to check the code with.
Shannon V. OKeets
Posts: 22165
Joined: Wed May 18, 2005 11:51 pm
Location: Honolulu, Hawaii
Contact:

RE: WIfCon 2010

Post by Shannon V. OKeets »

ORIGINAL: brian brian

I noticed an obscure thing for the soon to be new supply routines do properly. Will they trace supply across frozen lake hexsides? They become river hexsides in winter. Then there are those extra tricky lakes that lay on weather boundaries.... just a thought to check the code with.
Supply is redetermined whenever the weather changes - obviously. Supply is not assumed to be the same as previously. It is just that the previous path is tested to see if it is still valid. Any units that were out-of-supply previously are always checked.
Steve

Perfection is an elusive goal.
Post Reply

Return to “World in Flames”