Rails Pathfinding

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
libik
Engineer
Engineer
Posts: 43
Joined: 18 Nov 2006 11:39

Rails Pathfinding

Post by libik »

Hey,
I was really happy to find out that there is Pathfinder included in AI script. I mean the `import("pathfinder.rail", "RailPathFinder", 1);`

I tested it already and it is GOD DAMN SLOW! Even for short route (100 manhattan distance) it takes more than in-game year to find a route.

Is there any better easy to use alghoritm for it? I was hoping to not write it from scratch by myself - it does not have to produce perfect routes, just reasonable routes in reasonable time.

So is there something else that is usable for competitive experience? (I would like the AI to perform well or even better than veteran players, especially in later stages - for it I need to build fast).

EDIT: As the complexity increases exponencially, smaller paths dont take that much (i.e. 20 tiles takes just 3 in-game days). I can probably do it in a way by splitting it to several smaller paths of about 20 tiles away and then build them. But was hoping in something better :)

EDIT2: So POC works - I was able to create 130 diagonal (260 manhattan distance) in just 4 months on simple terrain
Screenshot 2023-09-08 214647.png
Screenshot 2023-09-08 214647.png (275.77 KiB) Viewed 1166 times
EDIT3: When map is simple and travelling in mostly non-diagonal direction, its even faster - in 4 months it was able to create the 500 long track (including pathfinding + actual buildling on medium speed)
Screenshot 2023-09-08 220020.png
(744.48 KiB) Not downloaded yet
Last edited by libik on 08 Sep 2023 20:03, edited 3 times in total.
Hi all
libik
Engineer
Engineer
Posts: 43
Joined: 18 Nov 2006 11:39

Re: Rails Pathfinding

Post by libik »

Or do any of you knows AI that performs really well when building really long rail tracks?
Hi all
AAAHogEx
Engineer
Engineer
Posts: 117
Joined: 30 Jan 2022 15:37
Location: Japan

Re: Rails Pathfinding

Post by AAAHogEx »

Hi, libik

AAAHogEx was able to accelerate the search speed with the following simple modification.

In the standard RailPathFinder, the A* evaluation function operates on "the cost from the start" + "the estimated cost to the goal", with both values being set to be approximately the same. However, by making the estimated cost to the goal significantly heavier (for instance, doubling it), it generally tends to initiate the search from the side closer to the goal, which is advantageous in most cases.

However, this method can become disadvantageous when the terrain is complex, as it takes a very long time to conduct a search in situations where it is necessary to take a detour to reach the destination. Therefore, AAAHogEx is adopting an approach where it manages to reach the destination through the use of tunnels, bridges, and terrain shaping.

Looking forward to the new AI!
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 23 guests