Transport Tycoon Forums

The place to talk about Transport Tycoon
It is currently Sat May 25, 2019 12:09 pm

All times are UTC




Post new topic  Reply to topic  [ 11 posts ] 
Author Message
PostPosted: Wed Apr 08, 2009 1:47 pm 
Offline
Transport Coordinator
Transport Coordinator
User avatar

Joined: Fri Dec 19, 2008 5:03 am
Posts: 316
Location: Indonesia
Rail pathfinder use existing rail.
Attachment:
File comment: Main RailPF
main.nut [23.97 KiB]
Downloaded 94 times

The Diff from version 1.0
Attachment:
File comment: Diff from version 1.0
railpf.diff [22.56 KiB]
Downloaded 113 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 ...

_________________
Correct me If I am wrong - PM me if my English was bad :D

**[OpenTTD AI]** Image
***[NewGRF] *** Image


Last edited by fanioz on Mon Jul 27, 2009 9:31 am, edited 1 time in total.

Top
   
PostPosted: Wed Apr 08, 2009 6:05 pm 
Offline
President
President
User avatar

Joined: Sun Jun 03, 2007 10:22 pm
Posts: 950
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


Top
   
PostPosted: Wed Apr 08, 2009 10:57 pm 
Offline
Transport Coordinator
Transport Coordinator
User avatar

Joined: Fri Dec 19, 2008 5:03 am
Posts: 316
Location: Indonesia
Ah. I see ....
Code:
/**
     * 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:
myclass.InitializePath(from, to, , ,ignored_tiles)




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

_________________
Correct me If I am wrong - PM me if my English was bad :D

**[OpenTTD AI]** Image
***[NewGRF] *** Image


Top
   
PostPosted: Thu Apr 09, 2009 1:08 am 
Offline
Tycoon
Tycoon

Joined: Thu Dec 20, 2007 12:49 pm
Posts: 3653
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.
Quote:
One thing I've never check, is squirrel can be used this way ? (blank parameter)
Code:
myclass.InitializePath(from, to, , ,ignored_tiles)
I don't think so, but maybe it's possible.


Top
   
PostPosted: Thu Apr 09, 2009 12:30 pm 
Offline
Transport Coordinator
Transport Coordinator
User avatar

Joined: Fri Dec 19, 2008 5:03 am
Posts: 316
Location: Indonesia
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:
local args = [this, path, new_tile]


Attachments:
Rail.pf.diff [23.21 KiB]
Downloaded 93 times

_________________
Correct me If I am wrong - PM me if my English was bad :D

**[OpenTTD AI]** Image
***[NewGRF] *** Image
Top
   
PostPosted: Mon Jun 15, 2009 2:17 pm 
Offline
Transport Coordinator
Transport Coordinator
User avatar

Joined: Fri Dec 19, 2008 5:03 am
Posts: 316
Location: Indonesia
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)


Attachments:
File comment: Revised: RailPF with Aystar.6
main.nut [20 KiB]
Downloaded 123 times
File comment: Revised : Diff file
railpf.diff [16.25 KiB]
Downloaded 90 times

_________________
Correct me If I am wrong - PM me if my English was bad :D

**[OpenTTD AI]** Image
***[NewGRF] *** Image


Last edited by fanioz on Mon Jun 15, 2009 2:31 pm, edited 1 time in total.
Top
   
PostPosted: Mon Jun 15, 2009 2:25 pm 
Offline
Tycoon
Tycoon

Joined: Thu Dec 20, 2007 12:49 pm
Posts: 3653
Did you really test this exact version? In that case I'd retry without this addition:

Code:
-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;


Top
   
PostPosted: Mon Jun 15, 2009 2:33 pm 
Offline
Transport Coordinator
Transport Coordinator
User avatar

Joined: Fri Dec 19, 2008 5:03 am
Posts: 316
Location: Indonesia
Yexo wrote:
Did you really test this exact version? In that case I'd retry without this addition:

Code:
-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

_________________
Correct me If I am wrong - PM me if my English was bad :D

**[OpenTTD AI]** Image
***[NewGRF] *** Image


Top
   
PostPosted: Sun Jul 12, 2009 4:25 pm 
Offline
Director
Director
User avatar

Joined: Tue Jan 22, 2008 4:33 pm
Posts: 565
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. ?(

_________________
PathZilla - A networking AI - Now with tram support.


Top
   
PostPosted: Mon Jul 13, 2009 12:40 pm 
Offline
Transport Coordinator
Transport Coordinator
User avatar

Joined: Fri Dec 19, 2008 5:03 am
Posts: 316
Location: Indonesia
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. :)

_________________
Correct me If I am wrong - PM me if my English was bad :D

**[OpenTTD AI]** Image
***[NewGRF] *** Image


Top
   
PostPosted: Mon Jul 27, 2009 9:34 am 
Offline
Transport Coordinator
Transport Coordinator
User avatar

Joined: Fri Dec 19, 2008 5:03 am
Posts: 316
Location: Indonesia
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:

_________________
Correct me If I am wrong - PM me if my English was bad :D

**[OpenTTD AI]** Image
***[NewGRF] *** Image


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 11 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000-2019 phpBB Limited

Copyright © Owen Rudge/The Transport Tycoon Forums 2001-2019.
Hosted by Zernebok Hosting.