MinchinWeb's MetaLibrary  v.9
Library functions of OpenTTD AI writers.
readme.md
Go to the documentation of this file.
1 About MetaLibrary {#mainpage}
2 ===============================================================================
3 
4 MetaLibrary is the collection of code I've written for
5 [WmDOT](http://www.tt-forums.net/viewtopic.php?f=65&t=53698), my AI for
6 [OpenTTD](http://www.openttd.org/), that I felt should properly be in a
7 library. Separating my AI from this library has made it easier to write my
8 AI, but I also hope will this code will help some aspiring AI writer get off
9 the ground a little bit faster. ;)
10 
11 GameScript
12 ===============================================================================
13 A GameScript version of this library is also available. All functions are
14 available, although some may require an active company context.
15 
16 Sub-Libraries Available {#sublibraries}
17 ===============================================================================
18 
19 - `%MinchinWeb.Atlas` ← \_MinchinWeb\_Atlas\_
20  - given a list of 'sources' and 'attractions', will weight the combinations
21  and generate a list of pairs to connect.
22 - `%MinchinWeb.Array` ← \_MinchinWeb\_Array\_
23  - Array functions
24 - `%MinchinWeb.Constants` ← \_MinchinWeb\_C\_
25 - `%MinchinWeb.DLS` ← \_MinchinWeb\_DLS\_
26  - **Dominion Land System** -- a wrapper on the road pathfinder to encourage
27  roads to be built on a grid.
28 - `%MinchinWeb.Extras` ← \_MinchinWeb\_Extras\_
29  - Extra functions, for things like math, map geometry, ship support, etc.
30 - `%MinchinWeb.Lakes` ← \_MinchinWeb\_Lakes\_
31  - **Lakes** serves as a check to determine if two points are in the same
32  waterbody. It was written as a replacement for Waterbody Check. Lakes
33  remembers the work it has previously done, which makes subsequent requests
34  much faster.
35 - `%MinchinWeb.LineWalker` ← \_MinchinWeb\_LW\_
36  - **Line Walker** -- walk the map between two points, or start at a given
37  point and walk out at a given slope.
38 - `%MinchinWeb.Log` ← \_MinchinWeb\_Log\_
39  - help (dynamically) control the amount of debugging output displayed.
40 - `%MinchinWeb.Industry` ← \_MinchinWeb\_Industry\_
41 - `%MinchinWeb.Marine` ← \_MinchinWeb\_Marine\_
42  - Marine and ship related functions.
43 - `%MinchinWeb.ShipPathfinder` ← \_MinchinWeb\_ShipPathfinder\_
44  - A geometry based Ship Pathfinder.
45 - `%MinchinWeb.SpiralWalker` ← \_MinchinWeb\_SW\_
46  - **Spiral Walker** -- allows you to define a starting point, and then
47  'walk' all the tiles in a spiral outward. It was originally used to find a
48  buildable spot for my HQ in WmDOT, but is useful for many other things as
49  well.
50 - `%MinchinWeb.Station` ← \_MinchinWeb\_Station\_
51  - some station related functions
52 - `%MinchinWeb.RoadPathfinder` ← \_MinchinWeb\_RoadPathfinder\_
53  - Based on NoAI Team's pathfinder. The pathfinder uses the A* search pattern
54  and includes functions to find the path, determine its cost, and build it.
55  Can bridge over rivers, canals, and railroad tracks.
56 - `%MinchinWeb.WaterbodyCheck` ← \_MinchinWeb\_WBC\_
57  - **Note**: Waterbody Check has been deprecated in favour of Lakes
58  - Waterbody Check - in effect a specialized pathfinder. It serves to check
59  whether two points are in the same waterbody (i.e. a ship could travel
60  between them). It is optimized to run extremely fast (I hope!). It can be
61  called separately, but was originally designed as a pre-run check for my
62  Ship Pathfinder.
63 
64 Changelog
65 ===============================================================================
66 ### Version 9
67 
68 Released 2015-01-10
69 
70 - bug fix to Python build script (specifically, fix NoGo library version)
71 - update build script to work with Python 3000
72 
73 Read the complete [Changelog](md_openttd-metalibrary_changelog.html).
74 
75 Installation {#installation}
76 ===============================================================================
77 
78 The easiest way install MetaLibrary is the use the in-game downloader in
79 OpenTTD.
80 
81 If you want to manually install it, download the folder and place it in your
82 `../OpenTTD/ai/library/` folder.
83 
84 For you to use the library in your AI's you'll need to import it. Somewhere
85 outside of any other class or function, add an import statement like:
86 
87  Import("util.MinchinWeb", "MinchinWeb", 9);
88 
89 Requirements {#requirements}
90 ===============================================================================
91 
92 If installed from the in-game downloader, the dependencies will
93 automatically be downloaded and installed. Otherwise, you'll need the
94 following libraries:
95 
96 - [Binary Heap], v.1 (`Queue.BinaryHeap-1.tar`)
97 - [Fibonacci Heap], v.3 (`Queue.FibonacciHeap-3.tar`)
98 - [Graph.AyStar], v.6 (`Graph.AyStar-6.tar`)
99 
100 [Binary Heap]: http://binaries.openttd.org/bananas/ailibrary/Queue.BinaryHeap-1-1.tar.gz
101 [Graph.AyStar]: http://binaries.openttd.org/bananas/ailibrary/Graph.AyStar-6-1.tar.gz
102 [Fibonacci Heap]: http://binaries.openttd.org/bananas/ailibrary/Queue.FibonacciHeap-3.tar.gz
103 
104 OpenTTD is able to read uncompressed `tar` files without any problem.
105 
106 FAQ {#faq}
107 ===============================================================================
108 
109 **Q:** How do I use the sub-libraries directly?
110 
111 **A:** Import the main library, and then create global points to the
112  sub-libaries you want to use. Eg:
113 ~~~
114  Import("util.MinchinWeb", "MinchinWeb", 9);
115  Arrays <- MinchinWeb.Arrays;
116 ~~~
117 *Info:* See the sub-library files for the functions available and their
118  implementation.
119 
120 **Q:** What is the \_MinchinWeb\_ ... all over the place?
121 
122 **A:** I can't answer it better than Zuu when he put together his SuperLib, so
123  I'll quote him.
124 
125 > " Unfortunately due to constraints in OpenTTD and Squirrel, only the
126 > main class of a library will be renamed at import. For [MetaLib]
127 > that is the [MetaLib] class in this file. Every other class in this
128 > file or other .nut files that the library is built up by will end
129 > up at the global scope at the AI that imports the library. The
130 > global scope of the library will get merged with the global scope
131 > of your AI.
132 >
133 > " To reduce the risk of causing you conflict problems this library
134 > prefixes everything that ends up at the global scope of AIs with
135 > [ \_MinchinWeb\_ ]. That is also why the library is not named Utils or
136 > something with higher risk of you already having at your global
137 > scope.
138 >
139 > " You should however never need to use any of the [ \_MinchinWeb\_ ... ]
140 > names as a user of this library. It is not even recommended to do
141 > so as it is part of the implementation and could change without
142 > notice. "
143 >
144 > -- Zuu, SuperLib v.7 documentation
145 
146 A grand 'Thank You' to Zuu for his SuperLib that provided a very useful
147  model, to all the NoAI team to their work on making the AI system work,
148  and to everyone that has brought us the amazing game of OpenTTD.
149 
150 License {#license}
151 ===============================================================================
152 
153 **Minchinweb's MetaLibrary** v.9 [2015-01-10]
154 
155 Copyright © 2011-15 by W. Minchin.
156 For more info,
157  please visit <https://github.com/MinchinWeb/openttd-metalibrary>
158 
159 Permission is granted to you to use, copy, modify, merge, publish,
160 distribute, sublicense, and/or sell this software, and provide these
161 rights to others, provided:
162 
163 - The above copyright notice and this permission notice shall be included
164  in all copies or substantial portions of the software.
165 - Attribution is provided in the normal place for recognition of 3rd party
166  contributions.
167 - You accept that this software is provided to you "as is", without warranty.
168 
169 \note \_MinchinWeb\_RoadPathfinder\_ is separately licensed under
170  LGPL v.2.1.
171 
172 Links {#links}
173 ===============================================================================
174 - Discussion thread for MetaLibarary on TT-Forums --
175  <http://www.tt-forums.net/viewtopic.php?f=65&t=57903>
176 - MetaLibrary code, hosted on GitHub --
177  <https://github.com/MinchinWeb/openttd-metalibrary/>
178 - MetaLibrary documentation --
179  <http://minchin.ca/opettd-metalibrary/>
180 
181 Notes To Me {#notes}
182 ===============================================================================
183 \todo Notes about static classes, what they are, and which classes
184  are 'static'
185 \todo Consider Fibonacci Heap version in NoCAB
186 \todo Add picture of in game downloader
187 \todo Look into theming dOxygen output
188 \todo Add 'News' tab pointing back to my Blog updates on MetaLibrary