Ship Pathfinder (MinchinWeb's MetaLibrary)
Posted: 31 Jan 2012 05:02
When looking to expand my AI (WmDOT) last spring, I decided to add some ships. First though, I needed a pathfinder. I decided to create a pathfinder based on geometry rather than using the A* approach I used for roads. My pathfinder works like this:
So I post this here to share my work that it might be helpful/inspire someone else, and if anyone has suggestions on how to get around having to use WaterbodyCheck or how to speed up the pathfinder or WaterbodyCheck Lakes.
The pathfinder is included in my MetaLibrary (also available on Bananas). I have attached a small AI below that you can use to see to help you understand how the pathfinder works.
Update (2014-02-28): v7 of MetaLibrary has been release that includes Lakes. The AI has been updated to test the workings of the Ship Pathfinder, Waterbody Check, and Lakes. To see all the signs, set Debug Level to 8.
- To initialize, a path with two points (the start and end) is added to the pathfinder. For each following loop:
- The shortest (unfinished) path is pulled from the pathfinder
- The path is walked, point-to-point, until land is reached
- If land is reached, two lines are drawn at right angles starting the midpoint (of the land). If water if reached, that point is then added to the path, and the path is added to the 'unfinished' list.
- If the shortest path is on the 'finished' list (i.e. all water), then that path is returned. Otherwise, the loop restarts.
So I post this here to share my work that it might be helpful/inspire someone else, and if anyone has suggestions on how to get around having to use WaterbodyCheck or how to speed up the pathfinder or WaterbodyCheck Lakes.
The pathfinder is included in my MetaLibrary (also available on Bananas). I have attached a small AI below that you can use to see to help you understand how the pathfinder works.
Update (2014-02-28): v7 of MetaLibrary has been release that includes Lakes. The AI has been updated to test the workings of the Ship Pathfinder, Waterbody Check, and Lakes. To see all the signs, set Debug Level to 8.