AI rail pathfinder and 45 degree turns

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
User avatar
Michiel
Transport Coordinator
Transport Coordinator
Posts: 339
Joined: 13 Jul 2008 00:57
Contact:

AI rail pathfinder and 45 degree turns

Post by Michiel »

Is there an easy way to tweak the rail pathfinder to penalize two 45 degree turns after eachother? I'd like to discourage it from choosing corner type A, and prefer type B:

Image
User avatar
lawton27
Tycoon
Tycoon
Posts: 1418
Joined: 03 Aug 2009 14:29
Location: Manchester

Re: AI rail pathfinder and 45 degree turns

Post by lawton27 »

I don't know about tweaking the pathfinder but you could add a penalty station, way-point or level crossing after 2 45 degree turns so the route is less favourable.
User avatar
Michiel
Transport Coordinator
Transport Coordinator
Posts: 339
Joined: 13 Jul 2008 00:57
Contact:

Re: AI rail pathfinder and 45 degree turns

Post by Michiel »

Thanks, but I don't mean the train's pathfinder, but the NoAI library that's used to build the rails.
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: AI rail pathfinder and 45 degree turns

Post by Zuu »

If the rail pf has the same structure as the road pf, you want to make your own MyPF : RailPF that overrides the default _Cost function. You may first call the RailPF::_Cost function to get the default cost and then add your own penalties.

Check eg. Admiral AI and see if it uses this technique to penalize level crossings with road. CluelessPlus implements its own _Cost and _Neighbour functions, but for the road pathfinder so it might be more useful for you if you can find a rail-AI that has a custom _Cost function.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
User avatar
Michiel
Transport Coordinator
Transport Coordinator
Posts: 339
Joined: 13 Jul 2008 00:57
Contact:

Re: AI rail pathfinder and 45 degree turns

Post by Michiel »

I think it does, I'll have a look.
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: Google [Bot] and 8 guests