For new players: are you looking for an AI to add to your game? Give ChooChoo a go!
It is stable, it builds aesthetically pleasing train networks, and it's quite resilient without being murderously competitive.
Hi everyone, I would like to present ChooChoo, a train network AI. I've tried to make something that builds "interesting", nice looking networks. It works by placing a four way crossing at a randomish location and extending its rail network to towns in 4 directions. It'll build a train station on the outskirts of town, with a small bus service to the city center and nearby towns. 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:
It aims to create simple, but nice looking crossings and good looking bridges:
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:
Picture of the new stations with bus service:
Known limitations:
- Limited load/save support (it'll "forget" the current work in progress).
- It probably won't behave nicely if there are 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.
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
Anyway, enjoy!
Updates
2009-07-09:
- improved startup
- evaluate seed crossing locations before building
- transports mail
- restricted to one station per town
2009-07-12:
- clean up failed crossing exits instead of capping them with depots
- engine selection should now work with newgrfs
- money management to prevent bankrupcy
2009-07-13:
- 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
2009-07-16:
- add a fixed number (currently 3) trains per new station and send them to stations that need more trains the most
2009-08-04:
- 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
2010-05-17:
- 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)
2010-05-17:
- 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
2010-05-25:
- 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)
2010-05-30:
- 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
2010-05-30a:
- fixed a terraforming bug
2010-06-05:
- fixed another terraforming bug
- cargo lines are now built single track at first, then extended to double track
- smaller terraforming footprint for crossings
2010-06-12:
- 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
2010-07-01:
- bus service to improve ratings (and because it looks nice)
- improved track building: smoother curves, obstacle avoidance and better double track layout
2011-03-13:
- 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
2011-03-14:
- double track: REALLY have the second track follow the first
2011-03-19:
- bug fix: don't build multiple stations at the same source industry
- shorter passenger trains
2012-03-28:
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
2017-08-26:
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
2023-03-16:
- fixed a crash when trying to sell off a vehicle that was already gone
- added an option (on by default) to keep running on unhandled errors
2023-03-23:
- uploaded to GitHub: https://github.com/mkonstapel/choochoo
2023-03-26:
- prefer shorter and nice looking bridges over ugly, fast ones
- tighter, neater double track
2023-03-30:
- significant improvements to pathfinder performance
2023-05-31:
- fixed signal placement so it doesn't create undersized signal blocks at station exits, which could cause deadlocks
2024-02-13:
- don't crash if mail doesn't exist as a cargo type
2024-03-04:
- add option for left hand traffic on double track
2024-03-07:
- add lake detector to avoid excessive pathfinding
2024-03-14:
- improved expansion algorithm