Station and Infrastructure Building
Relevant source files
The following files were used as context for generating this wiki page:
The Station and Infrastructure Building system in Trans AI is responsible for the physical manifestation of transportation networks within OpenTTD. It encompasses the logic required to construct airports, road stops, tram tracks, docks, and rail networks. This system ensures that the AI can effectively connect towns and industries to facilitate the transport of passengers and various cargo types.
The infrastructure logic is heavily influenced by the "Cargo Concept," which prioritizes a many-to-one delivery model where multiple sources feed into a single destination industry or town. The system also dynamically responds to game settings, such as infrastructure maintenance costs, which specifically impacts the decision-making process for air route expansion.
Sources: README.md:3-8, ROADMAP.md:33-40, ROADMAP.md:46-49
Infrastructure Types and Implementation
Trans AI implements infrastructure across four primary domains: Air, Road, Marine, and Rail. Each domain has specific building requirements and operational logic.
Air Infrastructure
The AI constructs airports to facilitate town-to-town passenger transport. It is programmed to utilize any available airport type and aircraft, including helicopters. A specialized implementation for helicopters involves connecting towns specifically to oil rigs.
Sources: ROADMAP.md:4-9
Road and Tram Tracks
Road infrastructure is divided between standard road vehicles (buses and trucks) and trams.
- Roads: Used for town-to-town passenger transit and industry-to-industry/town freight transport.
- Trams: Primarily used for passenger transport, though the AI also supports tram-trucks for freight, specifically targeting mail delivery when available.
Sources: ROADMAP.md:12-20
Marine Infrastructure
Marine routes rely on the construction of docks at industries or towns. A critical component of marine infrastructure building is the placement of buoys, which the AI uses to navigate and find proper paths through water bodies.
Sources: ROADMAP.md:22-25
Rail Networks
The rail system is primarily designed for transporting raw cargoes between industries. The infrastructure logic supports:
- Double Track: The AI attempts to build double tracks as a primary choice.
- Single Track: If double tracks are not buildable, the system falls back to a single-track configuration with a operational limit of two trains.
Sources: ROADMAP.md:27-31, ROADMAP.md:34-36
Infrastructure Decision Flow
The following diagram illustrates the high-level logic used when the AI decides to build infrastructure based on cargo type and environment settings.
The AI evaluates game-wide settings like infrastructure maintenance before committing to expensive builds, particularly for airports.
Sources: ROADMAP.md:46-49, ROADMAP.md:4-36
Infrastructure Components Summary
The table below summarizes the building requirements for each transport mode supported by the AI.
| Route Type | Primary Infrastructure | Secondary Infrastructure | Cargo Focus |
|---|---|---|---|
| Air | Airports | Heliports (Oil Rigs) | Passengers |
| Road | Road Stops | Depots | Passengers, Freight |
| Tram | Tram Stops | Tram Tracks | Passengers, Mail |
| Marine | Docks | Buoys | Passengers, Mail, Freight |
| Rail | Stations | Double/Single Tracks | Raw Cargoes |
Sources: ROADMAP.md:4-36
Cargo Concept and Many-to-One Building
A core architectural principle of the building module is the "Cargo Concept." Unlike standard point-to-point AIs, Trans AI attempts to build infrastructure that directs all cargo of a specific type to a single destination.
This strategy is currently implemented for Rail routes and is under development (50% complete) for Road and Marine routes.
Sources: ROADMAP.md:38-42
Infrastructure Maintenance Logic
The building system includes a detection mechanism for "Infrastructure Maintenance" settings. When this setting is enabled in the OpenTTD environment, the AI modifies its construction behavior. This is most critical for the Air Route module, where high maintenance costs for airports can lead to bankruptcy if not managed correctly.
Sources: ROADMAP.md:46-49
Conclusion
The Station and Infrastructure Building system serves as the physical backbone of the Trans AI. By supporting diverse vehicle types—from ships using buoys to trains using double tracks—the AI ensures a flexible and robust transport network. The integration of maintenance-aware building logic and the "Cargo Concept" demonstrates an architecture focused on long-term economic stability and efficient cargo throughput.