Page 2 of 2

Re: The Starlane Nexus

Posted: Tue Nov 05, 2019 12:01 pm
by Oberlus
I think I've made my first PR, #2631, not sure if I did it right.

Re: The Starlane Nexus

Posted: Tue Nov 05, 2019 2:17 pm
by alleryn
Oberlus wrote:
Tue Nov 05, 2019 9:57 am
Edit: Notice the absent starlane between Ster beta and the pale blue empty system in the SW corner. It is just outside of the maximum distance (250). Does anyone thing it should be connected?
Edit 2: no, it's not outside the maximum distance, it was connected when using MIN_PERP_DIST = 10 and MAX_LANE_DOT_PRODUCT = 0.87. I don't understand why increasing MIN_PERP_DIST forbids that starlane.
I too am a little confused why we are losing this starlane when MIN_PERP_DIST=10. My best guess is it's a system outside of the screenshot. There is a test that allows close objects sufficiently far but the condition is:

Code: Select all

// if object is further from either of the lane end systems than they
// are from eachother, it is fine, regardless of the right-angle
// distance to the line between the systems
if (dist2_12 < dist2_o1 || dist2_12 < dist2_o2)
     return false;
Since the distance between Ster B and the empty sw system is quite large, there may be something even further southwest that is prohibiting the starlane from being gernerated btwn Ster B and the empty Southwest.

Your solution of simply upping the MIN_PERP_DIST seems to have done the trick.
If it is producing undesirable results in this case or another case, another possibility is tightening the condition quoted above:

Could have instead, e.g.

Code: Select all

if (dist2_12 < alpha * dist2_o1 || dist2_12 < alpha * dist2_o2)
where alpha is bigger than 1. This would make the corridor around the starlane whose perpendicular proximity we are testing shorter. If alpha is too big, we would start admitting systems near the midpoint whose perpendicular distance was smaller than MIN_PERP_DIST.

Presumably, there is some minimum distance between any two systems (at least during universe generation?). If we have this constant it should be possible to come up with a good value for alpha.

Re: The Starlane Nexus

Posted: Thu Apr 02, 2020 8:20 am
by Oberlus
In order to alleviate the problem described here and here, I'm testing the following changes:

In the Starlane Bore (FOCS), add a restriction of 250 maximum distance (as in the Starlane Nexus):

Code: Select all

            scope = Object id = Source.SystemID
            effects = [
                AddStarlanes endpoint = MinimumNumberOf
                number = 1
                sortkey = DirectDistanceBetween object = Source.ID object = LocalCandidate.ID
                condition = And [
                    System
                    WithinDistance distance = 250 condition = Source  // <- HERE
                    CanAddStarlanesTo condition = Source
                ]
                GenerateSitRepMessage
                    message = "EFFECT_STARLANE_BORE"
                    label = "EFFECT_STARLANE_BORE_LABEL"
                    icon = "icons/tech/n-dimensional_structures.png"
                    parameters = tag = "system" data = Target.ID
                    empire = Source.Owner
                ]
I don't understand the syntax of this AddStarlanes effect, different from the one in the Starlane Nexus, I'm just guessing I put the WithinDistance condition in the right place.

In Conditions.cpp:

Code: Select all

        const float MAX_LANE_DOT_PRODUCT = 0.94f; // minimum angle between starlanes
                                                  // arccos(0.94) = 0.35 rad = 19.95 degrees
That is, forbid angles <20 degrees, while it was <30 before.

I don't have save files compatible with current master to test this, so I won't make the PR until I get some. But I have other things to do first, so if any of you stumble upon a situation good for this, please attach the save file here.

Re: The Starlane Nexus

Posted: Thu Apr 02, 2020 8:54 am
by Geoff the Medio

Code: Select all

                AddStarlanes endpoint = MinimumNumberOf
                number = 1
                sortkey = DirectDistanceBetween object = Source.ID object = LocalCandidate.ID
                condition = And [
                    System
                    WithinDistance distance = 250 condition = Source  // <- HERE
                    CanAddStarlanesTo condition = Source
                ]
I don't understand the syntax of this AddStarlanes effect, different from the one in the Starlane Nexus, I'm just guessing I put the WithinDistance condition in the right place.
The indenting is bit odd; should be more like

Code: Select all

                AddStarlanes endpoint = MinimumNumberOf
                    number = 1
                    sortkey = DirectDistanceBetween object = Source.ID object = LocalCandidate.ID
                    condition = And [
                        System
                        WithinDistance distance = 250 condition = Source  // <- HERE
                        CanAddStarlanesTo condition = Source
                    ]
Regardless, the MiniumNumberOf is a condition that selects a number of objects (in this case 1) by sorting them based on some sortkey (in this case their distance to the starlane bore object) after filtering with a condition. So it will first pick objects that match the condition, then for each calculate its distance to the source, then sort those, and pick the one with the shortest distance, and add a starlane between the effect target (the source's system) and the picked object.

The idea is that the bore adds a single lane to the single nearest suitable system, whereas the nexus adds lanes to all suitable systems.

That location for the WithinDistance filter looks OK.

Re: The Starlane Nexus

Posted: Thu Apr 02, 2020 9:27 am
by Oberlus
Thank you for the explanation, Geoff, really helpful.