Hi everyone, I would like to present ChooChoo, another train AI. I've tried to make something that builds "interesting", nice looking networks. For now, it just transports passengers and mail. It works by placing a four way crossing at a randomish location and extending its rail network to towns in 4 directions. When a destination town is "off to the side", it'll build a new crossing, connect the crossings and the station, and extend the newly placed crossing. This continues until the network can't be extended further. Then, it places a new seed crossing to build a new network. Here's a picture of the kind of network it builds:
And here's a screenshot of a nice set of crossings (links to a bigger one):
Picture of the new junction waypoints and station layout:
- Limited load/save support (it'll "forget" the current work in progress).
- It probably won't behave nicely when there's no trains available, so don't start the game in too early a year.
- It cheats a bit by extending its station coverage with bus stations; this requires "build on town roads" to be enabled.
- No train replacement except autorenew, but it will switch to new rail types when it starts a new network.
- Requires 0.7.2 or newer; 1.0 works fine.
It'll play nice with multiple instances of itself because they randomize their starting spots. It's also independent of map size.
Notes for those who want to peek inside:
I've implemented the main processing loop as a "to do list" of tasks. Each task is represented by an object, holding enough state so tasks can be broken off (usually due to running out of money, but it could also be a VEHICLE_IN_THE_WAY, etc.) and resumed. For example, building a crossing is a task (with several subtasks) which then pushes four new tasks onto the queue to expand its four exits.
I'm defining crossings and stations in a local coordinate system which can be moved and rotated to a place on the map. For example, the terminus stations have a single representation from which the four orientations are derived. Feel free to steal bits and pieces that look useful
- improved startup
- evaluate seed crossing locations before building
- transports mail
- restricted to one station per town
- clean up failed crossing exits instead of capping them with depots
- engine selection should now work with newgrfs
- money management to prevent bankrupcy
- don't block off crossings when expanding (can still accidentally block an unrelated one)
- start up with some cheap single track lines to get some revenue going
- add a fixed number (currently 3) trains per new station and send them to stations that need more trains the most
- save/load support
- clean up dead ends more neatly
- removed exit signals from crossings
- stations come with depots; less depots along tracks
- the usual handful of bug fixes
- fixed the broken tracks bug
- junctions now get a name in the form of a waypoint, making log output much easier to read (will probably become optional)
- better cleanup of dead track (try blocking a path being built)
- settings! Maximum bridge length, how many single track lines to start with, and whether to place waypoints at junctions are now configurable
- first train for a station gets full load orders to improve ratings
- build bus stations before trains to improve cargo production
- more options for station placement by considering the entire station area instead of just the "origin" tile
- handle events while waiting for money
- start with cargo, instead of passengers
- places signs showing what it's doing (optional)
- selectable path finder speed: trade off between speed and optimality (the new default is slightly faster than the old one)
- build a company HQ
- terrain levelling for stations
- plants trees to raise local authority ratings
- removed depots from tracks to prevent trains going into dead ends
- fixed a terraforming bug
- fixed another terraforming bug
- cargo lines are now built single track at first, then extended to double track
- smaller terraforming footprint for crossings
- check for compatibility with game settings (allowed to build disjoint stations, drive through stations on town roads)
- cost estimates for bootstrap cargo lines
- single platform cargo stations
- save money to autorenew vehicles
- ignore very small (<200 population) towns
- a whole bunch of bug fixes, including one that would cause it to miss a lot of cargo opportunities
- bus service to improve ratings (and because it looks nice)
- improved track building: smoother curves, obstacle avoidance and better double track layout
- several start up and profit related improvements, including better cargo route selection
- double track: have the second track follow the first
- try to place more crossings to grow larger networks
- double track: REALLY have the second track follow the first
- bug fix: don't build multiple stations at the same source industry
- shorter passenger trains
Wow, over a year since the last update! And it's mostly bug fixes:
- handle maps with no industries, and large maps with lots of industries
- fixed "Inconsistent compare function"
- "desync" multiple ChooChoo AIs by having them sleep for a short random time so they don't all try to build the same cargo routes
- fixed crash when there are no wagons available for a cargo type
Holy crap, has it been over five years?
- fixed an issue where the AI would be killed for using too much CPU time inside a valuator function