Jump to content
Rydygier

calculatePath - testing and considerations

Recommended Posts

To let know out of dev branch discussions and for various insights about usage of this command. Please, share with own observations, if any.

 

Tried new calculatePath command. Finds a path from Kavala to Pyrgos in 5-6 seconds. Then tested by putting BIKI example into some terrain-wise difficult cases. Troubles was expected and indeed encountered:

 

1. Destination cut off by water A:

 

- Code:

 

sleep 1;
time1 = diag_ticktime;

isNil {(calculatePath ["man","safe",(getMarkerPos "Start"),(getMarkerPos "End")]) addEventHandler ["PathCalculated",{
   
	hint format ["time: %1",(diag_ticktime - time1)];
   {
	
        _mrk = createMarker ["marker" + str _forEachIndex, _x];
        _mrk setMarkerType "mil_dot";
        //_mrk setMarkerText str _forEachIndex;

    } forEach (_this#1);
	
}];};

- positions:

 

Spoiler

calculate-Path-1.jpg

 

- result:

 

Spoiler

calculate-Path-1r.jpg

 

- time: 29,4s w/o drawing part

 

Kinda expected - code goes to swim only, if there's no any land path and it checks everywhere for it first. That would be my explanation of long execution time. 

 

2. Destination cut off by water B:

 

- code: same, as in test 1.

-  positions:

Spoiler

calculate-Path-2.jpg

 

- result:

 

NONE - gave up after two minutes of waiting. 

 

- time: ?

 

Well, cause may be similar, as in test 1, but despite visually simplier situation, algorithm might have much harder time, maybe searching even larger area due to its logic. Not sure. Anyway, that's a warning about that command's use. Can keep you hanging forever in certain cases. 

 

3. With loadingScreen

 

- code:

 


sleep 1;
time1 = diag_ticktime;
startloadingscreen [" ","RscDisplayLoadCustom"];
isNil {(calculatePath ["man","safe",(getMarkerPos "Start"),(getMarkerPos "End")]) addEventHandler ["PathCalculated",{
	endLoadingScreen;
	hint format ["time: %1",(diag_ticktime - time1)];
    {
	    _mrk = createMarker ["marker" + str _forEachIndex, _x];
        _mrk setMarkerType "mil_dot";
        //_mrk setMarkerText str _forEachIndex;
    } forEach (_this#1);
}];};

 

- positions:

 

Spoiler

calculate-Path-3.jpg

 

- result: 

 

NONE - code stuck behind loading screen.

 

- time: ?

 

I'm doing something wrong or it's a no go. A bit pity, it can't be speed up behind loadingScreen veil - will stuck forever there, maybe because it spawns an AI first and waits for it while simulation is suspended and spawned AI never ready?

 

 

 

Now, to leave some specific question, I was planning to use it in the function checking, if there's a land path possible between two positions. Sadly, long execution time, if there's no such path paired with loadingScreen incompatibility makes this approach impractical and leaves me with only simplified scripted solutions that would, say, check for water along straight line between two positions etc. imperfect workarounds, unless I miss something here? BTW I guess, path points density isn't customizable?

 

If someone's wondering, tried also with boats to see, if it will take into account peninsulas etc. with this code:

 


sleep 1;

time1 = time;
isNil {(calculatePath ["boat","safe",(getMarkerPos "Start"),(getMarkerPos "End")]) addEventHandler ["PathCalculated",{
    {
        _mrk = createMarker ["marker" + str _forEachIndex, _x];
        _mrk setMarkerType "mil_dot";
        //_mrk setMarkerText str _forEachIndex;
    } forEach (_this#1);
	
	diag_log "hop";
	hint format ["time: %1",(time - time1)];
}];};

 

It does:

 

Spoiler

calculate-Path-4.jpg

 

but:

 

Spoiler

calculate-Path-5.jpg

 

And if destination is on land:

 

Spoiler

calculate-Path-6.jpg

 

...it goes weird but hey, what to expect?

 

and opposite:

 

Spoiler

calculate-Path-7.jpg

 

Didn't tested:

land unit, both points on the water, 

land unit, start on the water,

land unit, end on the water,

boat, one point on the isolated water area (lake), other on the sea or another lake.

 

Finally - does this EH code run twice? Diag_log check confirms that. In total my impressions - most welcome command, great to have it, but somewhat risky in use (a risk of long, even infinite like long execution times, if "unlucky" at picked positions), and giving weird results in some weird situations. In current state impractical in some supposedly promising uses. 

  • Like 2
  • Thanks 5

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×