MetaLibrary 7 for OpenTTD released

MetaLibrary moves forward again!

Building off my recent announcement that documentation is now live, I have completed a fairly major update to MetaLibrary.

To recap, MetaLibrary is a collection of code I’ve written to simplify writing an AI for OpenTTD, a remake of my childhood favorite, Transport Tycoon.

This update particularly focused on adding robustness to the Ship Pathfinder. To that end, I wrote Lakes as a replacement for Waterbody Check. Both serve the same purpose of determining if two tiles are within the same waterbody, i.e. if a ship could sail between the two tiles. What sets Lakes apart from its predecessor is Lakes maintains a ‘memory’ of the tiles it has already considered, therefore increasing the speed of subsequent requests. Subsequent requests on an already checked route run in the order of 4 ticks, or about half of a game day.

Lakes has already seen a ten-fold increase in speed, although it, at least for the first run, is slower than the old Waterbody Check. New versions of MetaLibrary will likely continue to see speed ups and tweaks to Lakes.

Other improvements include:

  • Ship Pathfinder now uses Lakes rather than WaterBodyCheck
  • Ship Pathfinder now makes sure every point is in the same waterbody before adding it to the path
  • WaterBodyCheck is now deprecated in favour of Lakes
  • Documentation for MetaLibrary is now online at
  • Fix array creation bugs in Array.Create2D(), Array.Create3D()
  • Added Array.RemoveDuplicates(Array)
  • Added Array.ToAIList(Array)
  • Added Extras.MinDistance(TileID, TargetArray); can be used as a valuator
  • Split Constants from Extras (file only, function access remains the same)
  • Split Industry from Extras (file only, function access remains the same)
  • Split Station from Extras (file only, function access remains the same)
  • Bumped maximum Log Debug_Level to 8
  • Added separate Changelog file
  • Rename Readme.txt to
  • Update requirement to Fibonacci Heap, v.3
  • Automated creation of tar files for upload to BaNaNaS
  • Automated translation for the Game Script version

The forum thread for MetaLibrary discussion is on TT-Forums, the code for MetaLibrary is available on GitHub, the documentation for MetaLibrary is now online at, and MetaLibrary can be downloaded from BaNaNaS (AI version, GS version) or the in-game downloader (recommended).

Other posts

Other posts under MetaLibrary


There are no comments yet. Will you add the first one?

Add a Comment

You can use the Markdown syntax to format your comment.

or alternately, send me your thoughts at minchinweb [at]

Comment Atom Feed (for this post)