Rail Route Management
Relevant source files
The following files were used as context for generating this wiki page:
The Rail Route Management system within Trans AI is responsible for the automation of railway infrastructure and train operations. Its primary objective is the transport of raw cargo between industries, serving as a critical component of the AI's logistics network. The system is designed to handle different track configurations, prioritizing efficiency through double-track layouts while maintaining compatibility with simpler single-track setups.
Trans AI integrates rail management as part of its broader goal to transport cargo across all available vehicle types in OpenTTD. It specifically adheres to the "Cargo Concept," which emphasizes streamlining transport by targeting a single type of industry as a cargo destination whenever possible to optimize throughput.
Sources: README.md:3-8, ROADMAP.md:18-20
Infrastructure and Track Logic
The AI prioritizes the construction of robust rail networks to support industrial requirements. The logic follows a hierarchical approach to track building, ensuring that the infrastructure can support the intended volume of traffic.
Track Configurations
Trans AI supports two primary track configurations:
- Double Track Route: This is the preferred buildable configuration. It allows for high-capacity throughput by separating traffic directions.
- Single Track Route: If double tracks cannot be built, the AI falls back to a single track. In this mode, operations are strictly limited to a maximum of two trains to prevent gridlock or excessive waiting times.
Sources: ROADMAP.md:25-27
Connectivity Goals
The current implementation focuses on industrial logistics, though future milestones include expanding into passenger and multi-chain industry services.
| Feature | Status | Description |
|---|---|---|
| Raw Cargo Transport | Implemented | Transporting raw materials between primary industries. |
| Double Track Support | Implemented | Priority building of double tracks with single-track fallback. |
| Passenger Service | Planned | Future expansion to transport passengers between towns. |
| Multi-Chain Logistics | Planned | Future support for secondary/tertiary industry chains and town-affected cargoes. |
Sources: ROADMAP.md:18-24
Rail Operational Flow
The following diagram illustrates the decision-making process for rail route deployment, from cargo identification to track construction.
The flow demonstrates the AI's preference for double-track infrastructure and the operational constraints applied when limited to single tracks.
Sources: ROADMAP.md:18-27
Integration with Cargo Concept
The Rail Route Management system is being integrated into the AI's broader "Cargo Concept" (Many-to-one). This architectural pattern dictates that the AI attempts to use only one specific industry instance as the destination for a particular cargo type across the map.
Cargo Concept Progress
While the concept is established for other modes, the Rail Route implementation is a distinct development target:
- Status: The Cargo Concept for Rail Route is currently in development (following implementation in Road and Marine routes).
- Objective: To centralize industry deliveries, reducing the complexity of the rail network and maximizing the efficiency of industrial hubs.
Sources: ROADMAP.md:31-37, README.md:5-8
Technical Requirements and Dependencies
The rail system relies on standard OpenTTD AI libraries for pathfinding, list management, and string manipulation.
The AI utilizes external libraries to handle complex operations like list sorting for industry selection and common AI utilities.
Sources: README.md:46-51, info.nut
Development and Versioning
The rail module, like the rest of the project, follows a rolling release model. Versioning is handled automatically via GitHub Actions, ensuring that the latest rail pathfinding or logic improvements are tagged by date (YYMMDD).
Sources: README.md:53-61, .github/workflows/rolling-release.yml
Conclusion
Rail Route Management in Trans AI provides a specialized logic layer for industrial transport. By prioritizing double-track infrastructure and moving toward the "Cargo Concept" model, the system ensures scalable and efficient raw material logistics, with planned expansions into passenger services and complex industrial chains.