Page 1 of 1

Rail Path Finder modification

Posted: 08 Apr 2009 13:47
by fanioz
Rail pathfinder use existing rail.
main.nut
Main RailPF
(23.97 KiB) Downloaded 190 times
The Diff from version 1.0
railpf.diff
Diff from version 1.0
(22.56 KiB) Downloaded 209 times
================ First Post ====================
Since Aystar.5 has been uploaded on to Bananas, and the next version of Road Path Finder library seem nearly on the way to it goal. Here is Rail Path Finder modification. :oops:

Several days ago, I've asked (PM) yexo to start this thread. He said that right now, he is quite busy and let me to start posting.
So here was the proposed library (you could rename the extension to .nut) :D

Current modification ::
  • - Get the working pathfinder that use AyStar.5 feature (max.length, multiplier,.. etc)
  • - Add additional cost that similiar with RoadPF modification (except: no_existing_rail)
  • - Add custom cost call back too
I just have test it a few number and so far was so good. However it still need improvement. :lol:
Thanks for participating ...

Re: Rail Path Finder modification

Posted: 08 Apr 2009 18:05
by GeekToo
Well done Fanioz.

One remark, for backward compatibility and easier switching between the old and new rail pathfinder for comparison, could you please keep the order of the parameters of the InitializePath function like in the previous version:

So the ignored parameter before the new parameters.

That would prevent changing the caller's code when switching

Re: Rail Path Finder modification

Posted: 08 Apr 2009 22:57
by fanioz
Ah. I see ....

Code: Select all

/**
     * Initialize a path search between sources and goals.
     * @param sources The source tiles.
     * @param goals The target tiles.
     * @ignored_tiles The ignored tiles while pathfinding.
     * @param max_length_multiplier The multiplier for the maximum route length.
     * @param max_length_offset The minimum value of the maximum length.
     * @see AyStar::InitializePath()
     */
    function InitializePath(sources, goals, ignored_tiles = [], max_length_multiplier = 0, max_length_offset = 10000);
But, the caller format is based on Road Path finder modification. So, we may suggest this change too on them. :?:
One thing I've never check, is squirrel can be used this way ? (blank parameter)

Code: Select all

myclass.InitializePath(from, to, , ,ignored_tiles)


edit:: I really have to learn how to make good diff file :oops:

Re: Rail Path Finder modification

Posted: 09 Apr 2009 01:08
by Yexo
Nice work fanioz, I'll take a closer look as soon as I find the time for it.
fanioz wrote:But, the caller format is based on Road Path finder modification. So, we may suggest this change too on them. :?:
Suggest what you want, but I don't like to change the libraries too often (because a library upgrade requires an AI updated). The road pathfinder will not be changed unless bugs are found or major new features requested.
One thing I've never check, is squirrel can be used this way ? (blank parameter)

Code: Select all

myclass.InitializePath(from, to, , ,ignored_tiles)
I don't think so, but maybe it's possible.

Re: Rail Path Finder modification

Posted: 09 Apr 2009 12:30
by fanioz
Yexo wrote:
fanioz wrote:But, the caller format is based on Road Path finder modification. So, we may suggest this change too on them.
Suggest what you want, but I don't like to change the libraries too often (because a library upgrade requires an AI updated). The road pathfinder will not be changed unless bugs are found or major new features requested.
Emm... I mean suggest a modification in this thread, to keep InitializePath function like in the previous version of it, as GeekToo said above.
Okay, here is diff file compared to Rail PF ver 1.0 ( I hope I've made it correctly) :lol:

Change Log :
- keep InitializePath function like in the previous version
- Change the default parameter of Cost Call back to

Code: Select all

local args = [this, path, new_tile]

Re: Rail Path Finder modification

Posted: 15 Jun 2009 14:17
by fanioz
Because of avoid to use 'call', here is the Rail pathfinder revision. :lol: Still, this rail pathfinder tries to find a buildable and non existing route for rail vehicles.
* This is modified version to :
* - Use Aystar 6
* - Has similiar feature with Road.Path.Finder 4 (additional cost and cost callback function)
* - No longer use 'call' (actually the official version 1.0 never use it) :D
Tested so far with unreleased-TransAI.

=======
(test case to upload .nut file too, thanks to yexo for make suggestion of allowing .nut files)

Re: Rail Path Finder modification

Posted: 15 Jun 2009 14:25
by Yexo
Did you really test this exact version? In that case I'd retry without this addition:

Code: Select all

-function Rail::_Cost(path, new_tile, new_direction, self)
+function Rail::_Cost(self, path, new_tile, new_direction)
 {
 	/* path == null means this is the first node of a path, so the cost is 0. */
 	if (path == null) return 0;
+	return path.GetCost() + self._cost_tile;

Re: Rail Path Finder modification

Posted: 15 Jun 2009 14:33
by fanioz
Yexo wrote:Did you really test this exact version? In that case I'd retry without this addition:

Code: Select all

-function Rail::_Cost(path, new_tile, new_direction, self)
+function Rail::_Cost(self, path, new_tile, new_direction)
 {
 	/* path == null means this is the first node of a path, so the cost is 0. */
 	if (path == null) return 0;
+	return path.GetCost() + self._cost_tile;
My bad :oops: forget to remove that before uploading. That is because I want to test-use only Estimate().

Okay, it's now revised in above post

Re: Rail Path Finder modification

Posted: 12 Jul 2009 16:25
by Zutty
Nice job fanioz :)

However, I've had a quick play with your modified pathfinder and for some reason its much slower than the library pathfinder v1. I can't quite figure out why that is. ?(

Re: Rail Path Finder modification

Posted: 13 Jul 2009 12:40
by fanioz
Zutty wrote:Nice job fanioz :)

However, I've had a quick play with your modified pathfinder and for some reason its much slower than the library pathfinder v1. I can't quite figure out why that is. ?(
Thanks to remind me. :D
I still try to optimize it. However, feel free if you have any suggestion. :)

Re: Rail Path Finder modification

Posted: 27 Jul 2009 09:34
by fanioz
Pufff.... I think it is done now. :D :mrgreen: :lol: :o :)
Uploaded to the first post. However there are (maybe) something arguable (mm... discuss able??) things,, so please comment here. :bow: