trAIns is an AI for OpenTTD (the acronym AI will be adopted to denote a set of algorithms that control an agent in the game). The AI is called trAIns because it only constructs and manages railroad routes - one of the four transport types available in the game. The creation of trAIns has started as a graduation project that after became a research project. It has been written using the Squirrel language and the NoAI API. It can be downloaded and installed automatically using the game mechanism that manages on-line content.
There are two main reasons that explain why railroad routes have been chosen as the only transport type used. First, they have the most complex construction and management process as they incorporate almost all the challenges present in the construction and management of other transport types routes. Second, consequently in our opinion, there were/are few AIs that could/can use trains and generate good results according to the following metric.
A general metric of intelligence for AIs (and the chosen one for this context) is that its actions and decisions must result in behaviors similar to those caused by human players. Therefore, trAIns has been created to provide a competitive and intelligent AI that can play with railroads according to this concept. The following list enumerates the major trAIns features.
- The construction of railroads employs an abstraction called double parts that enables the construction of double railways. This approach permits many trains to circulate on the same route and also imitates one construction style of human players.
- Some special parts (named junctions parts) can be applied to branch the railroad. These branches allow the creation of complex railway networks (that is, several industries can have their production transported to one destination industry sharing parts of the railroad). Furthermore, this concept permits the concentration of production, another important strategy adopted by some players.
- The number of trains in each railroad route is computed dynamically. This dynamism permits the adjustment when the production increases or decreases or when another company starts to transport the industry production. The goal is to always keep at least one train waiting to be loaded in each loading station.
- trAIns can change the rail type to employ new locomotives. It will change the locomotive engine when it recognizes that the new one is the best engine available. During the evaluation, it considers the aspects: maximum reliability, running costs, maximum speed, power, weight and price.
- The railroad planner applies a carefully implemented version of A* algorithm. Its cost function is simple enough to avoid the expansion of several nodes and to permit the planning of relative long railways (250 tiles of length). In spite of the trade off between good railways (that is, straight lined railways) and fast planning, the planner can generate good results.
- It creates railroad routes that connects industries and railroad routes that connects two towns. The last can only transport passengers.
- During the railroad route management, trAIns can detect unprofitable routes and demolish them.
- It tries to select the industries with the largest potential of money generation. To do this, it considers the monthly production rate, the number of stations around the industry, the cargo type and the percentage of production transported last month.
- The town selection tries to avoid the towns that demands some cargo to grow.
- trAIns is partially compatible with the NewGRF files NARS (North American Renewal Set) and 2CC.
Downloads
Features planned for next releases
- Better junction placement to avoid strange results.
- Better NewGRF support.
- Build railroad routes to transport secondary/tertiary cargo.
- Build tunnels.
- Employ statues, advertising campaigns and buy exclusive transport rights when necessary.
- Handle industries that produces more than one cargo.
- Handle situations where the maximum loan is low (i.e. $200000 or $300000).
- Improve the pathfinding to increase its speed and to enhance the quality of generated railroads.
- Replace the old vehicles.
- Save and load support.
- Upgrade the bridges.
- Use terraforming on railroad construction.
Images
|
A railroad route with double railways that transport bubbles.
|
|
A junction branching the railroad route.
|
|
A railroad route that employs six trains to transport coal.
|
Release notes
- Version 2014_02_14 (trAIns v2.1):
- Improvement: Better bridge construction: it avoids, if possible, the construction of two consecutive bridges instead of only one. It also places signals "inside the bridge".
- Bug fix: Inconsistent compare function (thanks to Spyder, Samu and Kogut).
- Version 2010_02_07 (trAIns v2):
- Version 2009_10_11 (trAIns v1):
- Initial version using Squirrel and NoAI API.
- Version 2008_12_01 (Algorithms for NoAI):
- Initial version using C/C++.
References
- OpenTTD
- OpenTTD - Wikipedia, the free encyclopedia
- RIOS, L. H. O. Algoritmos de Inteligência Artificial para o Jogo OpenTTD. Universidade Federal de Minas Gerais, 2008, Belo Horizonte (PDF)
- RIOS, L. H. O. ; CHAIMOWICZ, L. . trAIns: An Artificial Inteligence for OpenTTD. In: VIII Simpósio Brasileiro de Jogos e Entretenimento Digital (SBGames 2009), 2009, Rio de Janeiro. Proceedings of the VIII Brazilian Symposium on Games and Digital Entertainment - ComputingTrack, 2009. p. 52-63. (PDF)