ShipPathFinder

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
Chruker
Engineer
Engineer
Posts: 49
Joined: 01 Jun 2009 20:13

ShipPathFinder

Post by Chruker »

Here is a pathfinder for ships.

This version can:
- Find its way across open waters :-)
- Build canals
- Build locks
- Build bridges

Some notes though:
- It still have the debugstatements, but they are commented out.

ShipPathFinder wish-list:
- Be able to do some simple terraforming at sealevel.
- Do some simple terraforming at heights to allow construction of bridges, locks and canals

There is also a new AyStar file, which have the following changes:
- Based of AyStar.6
- Added support for the users of Graph.AyStar to pass an additional variable in the neighbour arrays. The variable format for the Cost, Estimate and CheckDirection callbacks have had that variable added.
- Change: Internally the AyStar class was changed to use the variables in AyStar.Path instancies instead of the functions. This gives more speed.
- Change: FibonacciHeap instead of BinaryHeap which gives it a little bit more speed.
- Fix: Comments about which parameters are sent to the callbacks were outdated.
- Fix: When an AyStar.Path instance was used as source it didnt call the estimate function (not a big deal).

Edit 2009-07-06
- License-wise it is the same as the other AI libs (gpl2+)
Attachments
Pathfinder.Ship.x.nut
(25.02 KiB) Downloaded 219 times
Graph.AyStar.x.nut
(8.6 KiB) Downloaded 178 times
Last edited by Chruker on 06 Jul 2009 20:34, edited 2 times in total.
Chruker
Engineer
Engineer
Posts: 49
Joined: 01 Jun 2009 20:13

Re: ShipPathFinder

Post by Chruker »

A huge thanks must go to Yexo for providing answers to many many many questions on IRC
:bow:
Chruker
Engineer
Engineer
Posts: 49
Joined: 01 Jun 2009 20:13

Re: ShipPathFinder

Post by Chruker »

What are the opinions on the following things:
- Should the pathfinder build byous?
- The current version contains a BuildPath() function which builds the path, but I'm not sure if its usefull to have that in the library itself.
User avatar
fanioz
Transport Coordinator
Transport Coordinator
Posts: 320
Joined: 19 Dec 2008 05:03
Location: Indonesia
Contact:

Re: ShipPathFinder

Post by fanioz »

:D well done Chruker. I beleive once its available, many more AI will use it.
Personally I have no time right now to test it and look thoroughly at the code. But I would like to test it and maybe include them in future version of TransAI.
Chruker wrote:What are the opinions on the following things:
- Should the pathfinder build byous?
- The current version contains a BuildPath() function which builds the path, but I'm not sure if its usefull to have that in the library itself.
Here my opinion:
1. Bouys only build if the route is too long, it is not pathfinding part but path building part.
2. Therefore Buildpath doesnt needed to be included, as it not part of pathfinding. You may just show how to build using the path returned by this pathfinder. Similiarly with road and rail pathfinder, they have documentation on wiki.

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

**[OpenTTD AI]** Image
***[NewGRF] *** Image
User avatar
SirkoZ
Tycoon
Tycoon
Posts: 1518
Joined: 06 Mar 2004 23:51
Location: The sunny side of Alps

Re: ShipPathFinder

Post by SirkoZ »

Chruker wrote: - Should the pathfinder build byous?
I don't know about that but AI's certainly should and not far apart - as close as possible yet not too crowded - say - 10 to 12 squares apart like the NoCAB AI. This way it offloads CPU from ship pathfinding.
Morloth
Transport Coordinator
Transport Coordinator
Posts: 378
Joined: 07 Feb 2008 14:06
Location: Glasgow

Re: ShipPathFinder

Post by Morloth »

SirkoZ wrote:
Chruker wrote: - Should the pathfinder build byous?
I don't know about that but AI's certainly should and not far apart - as close as possible yet not too crowded - say - 10 to 12 squares apart like the NoCAB AI. This way it offloads CPU from ship pathfinding.
I actually noticed that if you place the buoys to far apart, ships can get lost. I now put one every 25 tiles, at least, to make sure ships are able to find their way. But I haven't really looked into this pathfinder framework, I don't suppose the road / rail pathfinder build anything but only return a list of tiles? In any case do what they do and you should be fine ^^.
Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: ShipPathFinder

Post by Yexo »

Chruker wrote:- Should the pathfinder build buoys?
The should be build ever 10/15 tiles, like SirkoZ says, but not by the pathfinder..
- The current version contains a BuildPath() function which builds the path, but I'm not sure if its useful to have that in the library itself.
I don't think the BuildPath function belongs in the pathfinder. The wiki is an excellent place to copy that function, so everyone can adapt it for his/her AI.
User avatar
skippern
Traffic Manager
Traffic Manager
Posts: 195
Joined: 30 Oct 2013 13:57

Re: ShipPathFinder

Post by skippern »

Is there still any development on this?

I will try to implement this, or parts of it into my Shipping AI that I just have started to develop (here)
Skippern
OpenTTD Mac user
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: Google Feedfetcher and 5 guests