Rail pathfinder.InitializePath clarification

Discuss the new AI features ("NoAI") introduced into OpenTTD 0.7, allowing you to implement custom AIs, and the new Game Scripts available in OpenTTD 1.2 and higher.

Moderator: OpenTTD Developers

Post Reply
kirky_D
Engineer
Engineer
Posts: 24
Joined: 25 Mar 2010 15:34

Rail pathfinder.InitializePath clarification

Post by kirky_D »

Hello there again!

Looking at the wiki this line confuses me a little bit.
The pathfinder expects an array of [start_tile, tile_before_start]-arrays and an array of [last_tile, tile_after_end]-arrays. since we only have one source and one goal tile, we'll just create two arrays with one element each. Now the pathfinder is ready to find a path.
I can get the pathfinder to find a path fine when I only have 1 set of start and end tiles, but if I have more than one it simply uses the first set of start tiles and the last set of end tiles. Can somebody tell what the point of adding in more start and end tiles is? The way I read it is that it will find a path for each set of start-end tiles, but this is not correct?

Cheers all!
Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: Rail pathfinder.InitializePath clarification

Post by Yexo »

No, it'll find a path between from any start tile to any end tile. If you want multiple paths you'll have to call the function multiple times.
User avatar
fanioz
Transport Coordinator
Transport Coordinator
Posts: 320
Joined: 19 Dec 2008 05:03
Location: Indonesia
Contact:

Re: Rail pathfinder.InitializePath clarification

Post by fanioz »

kirky_D wrote:I can get the pathfinder to find a path fine when I only have 1 set of start and end tiles
true
kirky_D wrote:but if I have more than one it simply uses the first set of start tiles and the last set of end tiles
AFAIK, it was not that 'simple'. The pathfinder would likely to choose the shortest pair (in distance).
kirky_D wrote:Can somebody tell what the point of adding in more start and end tiles is?
The pathfinder could use any of tile-set defined, not restricted to only one set.
kirky_D wrote:The way I read it is that it will find a path for each set of start-end tiles, but this is not correct?
For example Let's have:
Source = [a, b] [c,d] [e,f] [g,h]
Dest = [z, y][x,w][v,u]

The pathfinder will only find one path regardless how many set you have. Look, even the source and destination set count is not same.
If the shortest distance in map is between 'f' and 'u', the pathfinder would return:
First Tile = v, and last tile = e

Edit:: Yexo was faster :)
Correct me If I am wrong - PM me if my English was bad :D

**[OpenTTD AI]** Image
***[NewGRF] *** Image
kirky_D
Engineer
Engineer
Posts: 24
Joined: 25 Mar 2010 15:34

Re: Rail pathfinder.InitializePath clarification

Post by kirky_D »

Yeah that's pretty much what I thought.

Cheers guys!
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 9 guests