Fixing allied supply

For what's not in 'Top Priority Game Design'. Post your ideas, visions, suggestions for the game, rules, modifications, etc.

Moderator: Oberlus

Post Reply
Message
Author
Ophiuchus
Programmer
Posts: 3433
Joined: Tue Sep 30, 2014 10:01 am
Location: Wall IV

Fixing allied supply

#1 Post by Ophiuchus »

Ophiuchus wrote: Tue Oct 04, 2022 8:30 pm overall design idea of allied supply lines:

you can use them as if they are your own -> your planets in a system where an ally has won the supply should be able to use those

there is no reason to ever want allied supply to be cut off -> so biggest allied supply should win, your military ships should also not cut it off

(actually in a mixed alliance situation it may make sense to cut of another ally C, because you want to prioritize ally B; but basically it is ok to say the higher supply wins)
Ophiuchus wrote: Tue Sep 27, 2022 9:13 am one turn wrong effects on colonisation (out of own supply)
dunno

probably i should reread (Maybe) Bug: supply connection in FOCS and PP distribution differ
Ophiuchus wrote: Tue Sep 27, 2022 9:13 am multiple empires per system do not really work
they should; implementation idea: planets there should get there own supply group and then get merged
Ophiuchus wrote: Tue Sep 27, 2022 9:13 am planet may cut off allied supply. e.g. a zero-supply colony next to a high-supply allied system cutting off an asymetric supply connection (e.g. a 4-supply system would reach 4 hops, but only works up to the first allied colony)
should not be cut off, the higher allied supply should propagate
Ophiuchus wrote: Tue Sep 27, 2022 9:13 am multi-allied-supply
multiple empire-hops should work, only depending on your relation to those empires

Ophiuchus wrote: Sun Sep 18, 2022 7:46 am and we have another weirdness where there should be a supply connection by two allies to one system but it is disconnected from one side.

so system A is in empire A supply, system B 1-hop away is in empire B supply. system A has supply propagation 1. system B has supply propagation 0.

empire A and empire B are allies. system A should have a supply connection to system B, but it has not.
should be connected
Ophiuchus wrote: Tue Sep 27, 2022 9:13 am and some (in)determinism concerning enemy supply with equal values
wobbly wrote: Sun Sep 18, 2022 8:33 am There's also weirdness between enemies. MP 21st, turn 43. My 1 supply outpost is beating o01eg's 1 supply outpost. (Trixie y and Jera delta)
supply.cpp#460 there is some tie breaking stuff (bonus from colonies, outpost, multiple sources of supply...)
so most probably that was deterministic in a good way

we will document the tie breaker conditions somewhere in pedia
Notes, stringtables candidates for update:

SYSTEM_BLOCKADE_TEXT

METER_SUPPLY_VALUE_DESC - The main article explaining supply network etc..
planet size supply bonuses, UI explanation, 'Resource Group', PP distribution, refuel effect, enemy may break supply
"empires in an [[encyclopedia ALLIANCE_TITLE]] will share supply lines and all their associated benefits."

ALLIANCE_TEXT


hm. anybody knows what type empire_supply_it is (defined in Empire/Supply.cpp line 455) ? After analysing I do not agree with the code, which seems to say its a pointer to a pair(?, pair (hops,hops)):
float propagated_distance_to_supply_source = std::max(1.0f, empire_supply_it->second.second);
float propagated_range = empire_supply_it->second.first;

BEGINNER_HINT_04

PLC_NO_SUPPLY_DESC

Sidenote: [[metertype METER_SUPPLY]] is used in most places for saying "being in supply"


rereading (Maybe) Bug: supply connection in FOCS and PP distribution differ, which contains a lot of hints, the "one turn wrong effects on colonisation (out of own supply)" makes more sense;the problem meant was:
colonising out of your supply has the colony disconnected (no matter its target supply meter)

and the desired result is that it should be connected, if the supply meter is > 0 after effect evaluation.
Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.

Look, ma... four combat bouts!

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 13587
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: Fixing allied supply

#2 Post by Geoff the Medio »

Ophiuchus wrote: Wed Oct 05, 2022 9:44 amhm. anybody knows what type empire_supply_it is (defined in Empire/Supply.cpp line 455) ? After analysing I do not agree with the code, which seems to say its a pointer to a pair(?, pair (hops,hops)):
float propagated_distance_to_supply_source = std::max(1.0f, empire_supply_it->second.second);
float propagated_range = empire_supply_it->second.first;
https://github.com/freeorion/freeorion/ ... #L412-L455

Code: Select all


    // store (supply range in jumps, and distance to supply source) of all
    // unobstructed systems before propagation, and add to list of systems
    // to propagate from.
    std::map<int, std::map<int, std::pair<float, float>>> empire_propagating_supply_ranges;
    // ...
        for (auto& [empire_id, system_ranges] : empire_propagating_supply_ranges) {
            auto empire_supply_it = system_ranges.find(sys->ID());
            // does this empire have any range in this system? if so, store it
            if (empire_supply_it == system_ranges.end())
                // ...
system_ranges is a reference to a map<int, pair<float, float>>. map::find returns a map::iterator which effectively points to a pair<int, pair<float, float>>. Those are a system id, the propagating supply range for an empire at the system, and the distance to the dominant supply source for that empire that propagated into the system.

To clarify, if systems are arranged A - B - C - D and an empire has a supply source of strength 3 in A, then at A the range is 3 and the distance is 0, at B the range is 2 and the distance is 1, at C the range is 1 and the distance is 2, and at D the range is 0 and the distance is 3.

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 13587
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: Fixing allied supply

#3 Post by Geoff the Medio »

Ophiuchus wrote: Wed Oct 05, 2022 9:44 am
Ophiuchus wrote: Tue Sep 27, 2022 9:13 am multiple empires per system do not really work
they should; implementation idea: planets there should get there own supply group and then get merged
Ophiuchus wrote: Tue Sep 27, 2022 9:13 am planet may cut off allied supply. e.g. a zero-supply colony next to a high-supply allied system cutting off an asymetric supply connection (e.g. a 4-supply system would reach 4 hops, but only works up to the first allied colony)
should not be cut off, the higher allied supply should propagate
Seems to work as intended for me... I need a test save that demonstrates the problem, I guess.
production screenshot showing a zero supply system overwhelmed by ally supply that is connected to its homeworld and thus has production available
production screenshot showing a zero supply system overwhelmed by ally supply that is connected to its homeworld and thus has production available
supply_through_ally_network_to_zero_supply_planet.png (592.2 KiB) Viewed 1926 times

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 13587
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: Fixing allied supply

#4 Post by Geoff the Medio »

Test save attached. Player is at peace with the other empire and the networks don't merge, so the overpowered outpost is disconnected. After proposing an alliance and turn cycling, they do.
cut_off_supply.zip
supply test save
(69.76 KiB) Downloaded 131 times

Ophiuchus
Programmer
Posts: 3433
Joined: Tue Sep 30, 2014 10:01 am
Location: Wall IV

Re: Fixing allied supply

#5 Post by Ophiuchus »

Geoff the Medio wrote: Fri Oct 07, 2022 6:52 pm Seems to work as intended for me... I need a test save that demonstrates the problem, I guess.
the second issue (cut off propagation) would probably show if you get rid of the colony at Juthtath.
Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.

Look, ma... four combat bouts!

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 13587
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: Fixing allied supply

#6 Post by Geoff the Medio »

Some of the issues should be fixed after https://github.com/freeorion/freeorion/ ... 2937ae7ed7
-multi-step allied merging
-merging zero-supply systems with allies that have 1 supply range next to them

Might have introduced other bugs, though, so testing would be good.

Ophiuchus
Programmer
Posts: 3433
Joined: Tue Sep 30, 2014 10:01 am
Location: Wall IV

Re: Fixing allied supply

#7 Post by Ophiuchus »

Geoff the Medio wrote: Sun Oct 09, 2022 10:53 am Some of the issues should be fixed after
yay :)
Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.

Look, ma... four combat bouts!

Ophiuchus
Programmer
Posts: 3433
Joined: Tue Sep 30, 2014 10:01 am
Location: Wall IV

Re: Fixing allied supply

#8 Post by Ophiuchus »

Geoff the Medio wrote: Sun Oct 09, 2022 10:53 am Some of the issues should be fixed after https://github.com/freeorion/freeorion/ ... 2937ae7ed7
-multi-step allied merging
-merging zero-supply systems with allies that have 1 supply range next to them

Might have introduced other bugs, though, so testing would be good.
so, some reports:

stuff that works
  • artisan workshops increase influence output A-B-A; A planet (in A supply) .. B supply (via multiple B systems) .. A planet (in A supply) (if i remember correctly, could check in turn 104 slow game 021)
  • multi-empire system (not sure about details; check turn 104)
  • building colony via allied A-B-A. A colony (in A supply) .. A supply (via multiple A systems) .. B supply (via multiple B systems) .. A supply .. A system
stuff that does not work
  • prerequisite connection for building at empire A planet B-A-B-A; prerequisite at B planet (in B supply) .. B supply (multiple B systems) .. A supply (multiple A systems) .. 1 unowned system B supply .. building site A planet (A supplied)
Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.

Look, ma... four combat bouts!

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 13587
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: Fixing allied supply

#9 Post by Geoff the Medio »

Ophiuchus wrote: Fri Oct 14, 2022 7:41 pmprerequisite connection for building at empire A planet B-A-B-A; prerequisite at B planet (in B supply) .. B supply (multiple B systems) .. A supply (multiple A systems) .. 1 unowned system B supply .. building site A planet (A supplied)
Meaning an empire can't use an ally's building as a prerequisite for the first empire's production, even if a supply connection exists between the locations? Should they be able to?

User avatar
LienRag
Cosmic Dragon
Posts: 2146
Joined: Fri May 17, 2019 5:03 pm

Re: Fixing allied supply

#10 Post by LienRag »

They can use it if there's a direct A-B supply connection, but not if there's an ally between them.

Ophiuchus
Programmer
Posts: 3433
Joined: Tue Sep 30, 2014 10:01 am
Location: Wall IV

Re: Fixing allied supply

#11 Post by Ophiuchus »

Ophiuchus wrote: Fri Oct 14, 2022 7:41 pmprerequisite connection for building at empire A planet B-A-B-A; prerequisite at B planet (in B supply) .. B supply (multiple B systems) .. A supply (multiple A systems) .. 1 unowned system B supply .. building site A planet (A supplied)
i think i misdescribed the situation: we got actually rather a B-C-B-A situation.
Geoff the Medio wrote: Sat Oct 15, 2022 11:09 pm Meaning an empire can't use an ally's building as a prerequisite for the first empire's production, even if a supply connection exists between the locations? Should they be able to?
yes, they should be able to (in some cases/for some content). currently that is handled by checking for supply-connection plus ownership by an ally.
in principle could also be done on focs side with special kind of supply connection (if we add that in the backend).
Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.

Look, ma... four combat bouts!

Ophiuchus
Programmer
Posts: 3433
Joined: Tue Sep 30, 2014 10:01 am
Location: Wall IV

Re: Fixing allied supply

#12 Post by Ophiuchus »

Geoff the Medio wrote: Sun Oct 09, 2022 10:53 am Some of the issues should be fixed after https://github.com/freeorion/freeorion/ ... 2937ae7ed7
i had a look at the code to fix the example of an asteroid reformation processor for rock armor in allied space.
but actually everything looks like it should work
  • the FOCS condition uses the SupplyManager::m_resource_supply_groups
  • the supply groups are build in the SupplyManager::Update
  • the first steps result in ally_merged_supply_starlane_traversals
  • some magic happens (TBD)
  • in the end, for each empire a multi-graph is built (in form of an adjacency list), and a depth first search via boost::connected_components gives back labeled nodes. for each label the corresponding node set gets added to the m_resource_supply_groups
Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.

Look, ma... four combat bouts!

Ophiuchus
Programmer
Posts: 3433
Joined: Tue Sep 30, 2014 10:01 am
Location: Wall IV

Re: Fixing allied supply

#13 Post by Ophiuchus »

so test game setup with current weekly build.
three empires; A-B-1; empire 1 is allied with both A and B; A and B are at war.

supply groups map looks correct (all systems from all three empires)

Code: Select all

22:01:20.130127 {0x00007fa804a25780} [trace] supply : Supply.cpp:911 : Empire 1 supply groups map before merging:
22:01:20.130140 {0x00007fa804a25780} [trace] supply : Supply.cpp:913 :  ... 0 to: 0, 275, 
22:01:20.130156 {0x00007fa804a25780} [trace] supply : Supply.cpp:913 :  ... 25 to: 25, 265, 
22:01:20.130168 {0x00007fa804a25780} [trace] supply : Supply.cpp:913 :  ... 45 to: 45, 230, 
22:01:20.130181 {0x00007fa804a25780} [trace] supply : Supply.cpp:913 :  ... 55 to: 55, 70, 
22:01:20.130193 {0x00007fa804a25780} [trace] supply : Supply.cpp:913 :  ... 70 to: 55, 70, 230, 
22:01:20.130206 {0x00007fa804a25780} [trace] supply : Supply.cpp:913 :  ... 90 to: 90, 275, 
22:01:20.130219 {0x00007fa804a25780} [trace] supply : Supply.cpp:913 :  ... 105 to: 105, 140, 235, 
22:01:20.130231 {0x00007fa804a25780} [trace] supply : Supply.cpp:913 :  ... 130 to: 130, 140, 265, 
22:01:20.130243 {0x00007fa804a25780} [trace] supply : Supply.cpp:913 :  ... 135 to: 135, 140, 
22:01:20.130255 {0x00007fa804a25780} [trace] supply : Supply.cpp:913 :  ... 140 to: 105, 130, 135, 140, 
22:01:20.130278 {0x00007fa804a25780} [trace] supply : Supply.cpp:913 :  ... 160 to: 160, 275, 
22:01:20.130293 {0x00007fa804a25780} [trace] supply : Supply.cpp:913 :  ... 205 to: 205, 240, 
22:01:20.130305 {0x00007fa804a25780} [trace] supply : Supply.cpp:913 :  ... 220 to: 220, 245, 
22:01:20.130317 {0x00007fa804a25780} [trace] supply : Supply.cpp:913 :  ... 230 to: 45, 70, 230, 
22:01:20.130329 {0x00007fa804a25780} [trace] supply : Supply.cpp:913 :  ... 235 to: 105, 235, 245, 
22:01:20.130341 {0x00007fa804a25780} [trace] supply : Supply.cpp:913 :  ... 240 to: 205, 240, 265, 
22:01:20.130353 {0x00007fa804a25780} [trace] supply : Supply.cpp:913 :  ... 245 to: 220, 235, 245, 275, 
22:01:20.130366 {0x00007fa804a25780} [trace] supply : Supply.cpp:913 :  ... 265 to: 25, 130, 240, 265, 
22:01:20.130379 {0x00007fa804a25780} [trace] supply : Supply.cpp:913 :  ... 270 to: 270, 275, 
22:01:20.130391 {0x00007fa804a25780} [trace] supply : Supply.cpp:913 :  ... 275 to: 0, 90, 160, 245, 270, 275, 
supply groups looks unexpected; i would expect a single group; actually the four systems of empire A are in an own supply group

Code: Select all

22:01:20.131023 {0x00007fa804a25780} [debug] supply : Supply.cpp:973 : Connected supply groups for empire 1:
22:01:20.131035 {0x00007fa804a25780} [debug] supply : Supply.cpp:975 :  ... 0, 25, 90, 105, 130, 135, 140, 160, 205, 220, 235, 240, 245, 265, 270, 275, 
22:01:20.131052 {0x00007fa804a25780} [debug] supply : Supply.cpp:975 :  ... 45, 55, 70, 230, 
it looks like the traversal from A (230) <-> B (270) is missing:

Code: Select all

22:01:20.129205 {0x00007fa804a25780} [trace] supply : Supply.cpp:879 : Empire 1 supply traversals after merging allies 2 times:
22:01:20.129221 {0x00007fa804a25780} [trace] supply : Supply.cpp:882 :  ... 0 to 275
22:01:20.129233 {0x00007fa804a25780} [trace] supply : Supply.cpp:882 :  ... 25 to 265
22:01:20.129243 {0x00007fa804a25780} [trace] supply : Supply.cpp:882 :  ... 55 to 70
22:01:20.129253 {0x00007fa804a25780} [trace] supply : Supply.cpp:882 :  ... 70 to 55
22:01:20.129273 {0x00007fa804a25780} [trace] supply : Supply.cpp:882 :  ... 70 to 230
22:01:20.129285 {0x00007fa804a25780} [trace] supply : Supply.cpp:882 :  ... 90 to 275
22:01:20.129294 {0x00007fa804a25780} [trace] supply : Supply.cpp:882 :  ... 105 to 140
22:01:20.129304 {0x00007fa804a25780} [trace] supply : Supply.cpp:882 :  ... 105 to 235
22:01:20.129314 {0x00007fa804a25780} [trace] supply : Supply.cpp:882 :  ... 130 to 140
22:01:20.129324 {0x00007fa804a25780} [trace] supply : Supply.cpp:882 :  ... 130 to 265
22:01:20.129334 {0x00007fa804a25780} [trace] supply : Supply.cpp:882 :  ... 140 to 105
22:01:20.129344 {0x00007fa804a25780} [trace] supply : Supply.cpp:882 :  ... 140 to 130
22:01:20.129354 {0x00007fa804a25780} [trace] supply : Supply.cpp:882 :  ... 140 to 135
22:01:20.129364 {0x00007fa804a25780} [trace] supply : Supply.cpp:882 :  ... 160 to 275
22:01:20.129373 {0x00007fa804a25780} [trace] supply : Supply.cpp:882 :  ... 230 to 45
22:01:20.129383 {0x00007fa804a25780} [trace] supply : Supply.cpp:882 :  ... 230 to 70
22:01:20.129393 {0x00007fa804a25780} [trace] supply : Supply.cpp:882 :  ... 235 to 105
22:01:20.129403 {0x00007fa804a25780} [trace] supply : Supply.cpp:882 :  ... 235 to 245
22:01:20.129413 {0x00007fa804a25780} [trace] supply : Supply.cpp:882 :  ... 240 to 205
22:01:20.129423 {0x00007fa804a25780} [trace] supply : Supply.cpp:882 :  ... 240 to 265
22:01:20.129433 {0x00007fa804a25780} [trace] supply : Supply.cpp:882 :  ... 245 to 220
22:01:20.129442 {0x00007fa804a25780} [trace] supply : Supply.cpp:882 :  ... 245 to 235
22:01:20.129452 {0x00007fa804a25780} [trace] supply : Supply.cpp:882 :  ... 245 to 275
22:01:20.129474 {0x00007fa804a25780} [trace] supply : Supply.cpp:882 :  ... 265 to 25
22:01:20.129485 {0x00007fa804a25780} [trace] supply : Supply.cpp:882 :  ... 265 to 130
22:01:20.129495 {0x00007fa804a25780} [trace] supply : Supply.cpp:882 :  ... 265 to 240
22:01:20.129505 {0x00007fa804a25780} [trace] supply : Supply.cpp:882 :  ... 270 to 275
22:01:20.129515 {0x00007fa804a25780} [trace] supply : Supply.cpp:882 :  ... 275 to 0
22:01:20.129525 {0x00007fa804a25780} [trace] supply : Supply.cpp:882 :  ... 275 to 90
22:01:20.129534 {0x00007fa804a25780} [trace] supply : Supply.cpp:882 :  ... 275 to 160
22:01:20.129544 {0x00007fa804a25780} [trace] supply : Supply.cpp:882 :  ... 275 to 245
22:01:20.129555 {0x00007fa804a25780} [trace] supply : Supply.cpp:882 :  ... 275 to 270
Attachments
20221017_7060115_allied_supply_test.sav.zip
(510.14 KiB) Downloaded 119 times
Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.

Look, ma... four combat bouts!

Post Reply