It does this by modifying the existing YAPF ship pathfinder to first find the route to the destination over 'regions' of water. By using regions instead of tiles the pathfinder is orders of magnitude faster. The tile based pathfinder is then used to only find the route over the next couple of regions.
Use:
- Your pathfinder needs to be set to yapf before loading/generating as I haven't yet tested switching pathfinders mid-game.
- Starting openttd with '-d yapf=5' will show the regions on the sea and highlight the regions ships are going to (for a performance hit). Its fun to demolish a load of water and watch the regions grow back.
- I'm using m2 on water tiles to store the region index. For depots,docks and buoys this is used so I had to use (m3|(m4 >> 8 )).
- The tradeoff for faster route finding is that initial region find is done on world generation, then updated on any water terrain change. The extra ram usage is probably just under 2 bits per tile as the regions store their tiles via a bit array not as a list of TileIndex. (An idea from KUDr many moons ago)
- Region paths are not yet cached, but this could be done for even less CPU usage
- A similar approach could be used to find rail/road routes over land for the AIs, though this would be more complex.