Page 1 of 1

RPF (Road path finder) Updates - Version 4

Posted: 19 Aug 2012 10:43
by Zuu
Problem/solutions
In order to get out a RPF library for NoGo that is compatible with the AI version there are two options:
  • Release a new updated AI RPF that use AyStar 6 (instead of 4 as of now) as well as a NoGo version of this RPF that use the already ported AyStar 6 for NoGo.
  • Release a NoGo port of AyStar 4 as eg. "AyStar Classic" and use that as basis for a RPF port of RPF 3 for AIs.
What is worth to mention is that the order which the arguments to the callback-functions (cost, neighbours, etc.) are different in AyStar 4 and 6. Thus if you derive a RPF based on the stock RPF for AIs, it will not just simply work with a RPF based on AyStar 6, making it troublesome for projects like SuperLib that use the same code base to support both AIs and NoGo.

The first option (in the list above) give us a RPF based on AyStar 6 while the later will use AyStar 4 as the basis for both RPFs.

Selected solution - Make RPF 4 that depend on AyStar 6
After a discussion on IRC a few days ago the conclusion was that while AI authors that use RPF 3 will need to change about 4-5 lines of code when switching to RPF 4 (based on AyStar 6), that is still better as this is a good moment to introduce the API change and switch to AyStar 6.

The changes needed are eg:

Code: Select all

// from:
function _SuperLib_RoadPathFinder_private_CustomRPF::_Cost(path, new_tile, new_direction, self)
// to:
function _SuperLib_RoadPathFinder_private_CustomRPF::_Cost(self, path, new_tile, new_direction)

I've attached the new RPF 4 for AI and NoGo. These have not yet been committed at devZone or uploaded to bananas. I plan to also upload a new SuperLib at the same moment as RPF 4 is uploaded that support the new RPF version 4.

Edit: Removed attachments. Final tar files of RPF 4 have been uploaded to bananas.

Re: RPF (Road path finder) Updates

Posted: 19 Aug 2012 13:30
by Lord Aro
Note: if you want AI devs to use this, you'll need to get it uploaded to BaNaNaS asap

Just sayin' :)

Re: RPF (Road path finder) Updates

Posted: 19 Aug 2012 14:57
by Zuu
It will get uploaded to bananas within a few days or so. I was just telling ahead about the change.

Re: RPF (Road path finder) Updates - Version 4

Posted: 19 Aug 2012 22:13
by Zuu
Version 4 of Pathfinder.Road have been uploaded to BaNaNaS - both for AIs and Game Scripts.

If you have derived your own RPF class and overridden _Neighbours, _Estimate, etc. you will need to move the self parameter from the back of the argument list to the front for those functions. Otherwise you will run into errors and crashes. (see the code example in first post)

Also remember when uploading your next AI version to select the RPF as dependency again as it have now been deselected as you previously had version 3 selected and that one is not available anymore for new content to use. (unless TrueBrain or someone else get around to change it so that we can set old libraries as dependencies in bananas)

Re: RPF (Road path finder) Updates - Version 4

Posted: 01 Oct 2012 20:45
by Kogut
So it is only necessary to change code in places where _Cost function is somehow used?

Re: RPF (Road path finder) Updates - Version 4

Posted: 01 Oct 2012 20:50
by Zuu
_Cost, or any of the other callback functions (IIRC 5 in total). There is for example one that determines which neighbours there are, which is useful to customize in order to find solutions to bridge canals or rail tracks.

But if your only inherited RPF class is the one in KRAIpathfinder.nut, then you only have a customized _Cost callback.