
ChooChoo, a train network AI
Moderator: OpenTTD Developers
Re: ChooChoo, a train network AI
Thank you! I already stole some of the best bits
I'll probably make a new release in a few days.

Re: ChooChoo, a train network AI
New version! An actual update and not just a bug fix this time
The big red cantilever bridges ChooChoo was fond of building (because they are the fastest available at many lengths) have always been an eyesore to me. Now, I've changed the bridge selection to improve aesthetics: it prefers shorter bridges, so it's more often able to use the nice compact steel girders, and for longer bridges it now defaults to the nice coppery suspension bridges. They're slower, but who cares, it's all about looks!
I've also taught the pathfinder how to combine non-crossing track pieces, so double track lines can now be built tighter and neater by allowing the second track to share a tile with the first track, as long as they don't cross, as you can see at the north exit of the Penfingford Point junction. It also means that if it manages to find the first path, it's much more likely it'll be able to fit in the second track.
Snake like a snaky snake!

The big red cantilever bridges ChooChoo was fond of building (because they are the fastest available at many lengths) have always been an eyesore to me. Now, I've changed the bridge selection to improve aesthetics: it prefers shorter bridges, so it's more often able to use the nice compact steel girders, and for longer bridges it now defaults to the nice coppery suspension bridges. They're slower, but who cares, it's all about looks!

Snake like a snaky snake!
Re: ChooChoo, a train network AI
Another update: nothing to screenshot, but a major improvement in pathfinder performance, so ChooChoo should now be a lot more active. On my "torture test" map, finding a path dropped from 14 years to less than 2.
Fellow AI devs, if there is interest I can see if I can make some of the improvements available in the library pathfinder. The big one is removing the self-intersection test from aystar, which I don't need but could be made optional in the general purpose library implementation. The rest are various smaller improvements:
Fellow AI devs, if there is interest I can see if I can make some of the improvements available in the library pathfinder. The big one is removing the self-intersection test from aystar, which I don't need but could be made optional in the general purpose library implementation. The rest are various smaller improvements:
- using AIBinaryQueue
- caching cost estimates per tile (since they don't depend on direction)
- caching base costs per tile (costs independent of how you enter/leave the tile)
- shaving off a few ops by doing cheaper tests first in conditionals, pulling expressions out into local variables, etc.
- Redirect Left
- Tycoon
- Posts: 7417
- Joined: 22 Jan 2005 19:31
- Location: Wakefield, West Yorkshire
Re: ChooChoo, a train network AI
Hi there! Your AI struggled in tests for the AI list update for June. It created trains endlessly, until it jammed itself up. It now seems to be unable to correct the issue on this line by itself.
I've attached an image of the issue, and the savegame file.
I've attached an image of the issue, and the savegame file.
- Attachments
-
- CC oops image.png
- (708.08 KiB) Not downloaded yet
-
- CC Oops.sav
- (2.68 MiB) Downloaded 388 times
Re: ChooChoo, a train network AI
Its train management is quite limited, but that's not supposed to happen
I'll see if I can glean anything from the savegame, thanks for posting!

- Redirect Left
- Tycoon
- Posts: 7417
- Joined: 22 Jan 2005 19:31
- Location: Wakefield, West Yorkshire
Re: ChooChoo, a train network AI
It looks like at one of the stations, a train didn't clear (by only a pixel or so!) tracks, so next train couldn't go in, but also if it was trying to manage itself and delete minus revenue trains (if it does that anyway), it also couldn't do that to get out of the problem as it blocked the depot. Maybe a slight change to signals around stations may resolve it?Michiel wrote: 31 May 2023 12:32 Its train management is quite limited, but that's not supposed to happenI'll see if I can glean anything from the savegame, thanks for posting!
Re: ChooChoo, a train network AI
Wow, nice catch! I've never seen a jam like this, but that's obviously something that needs fixing. I'll see what I can do.
Re: ChooChoo, a train network AI
Ah, the problem is that the signal building was indeed subtly wrong. It builds paths "in reverse", so the first signal block out of a station, which is actually built last, might not have the required minimum length, causing a possible jam. I have a fix in the works.
Re: ChooChoo, a train network AI
Update released! It now builds all track from exit to entrance, so it can ensure proper sized signal blocks. That ought to fix the potential to deadlock the station exit. I also found out (after all these years!) that trains take up more tiles diagonally, so I've increased the distance between signals to ensure that a train will always fit in a block.Redirect Left wrote: 31 May 2023 07:21 Hi there! Your AI struggled in tests for the AI list update for June. It created trains endlessly, until it jammed itself up. It now seems to be unable to correct the issue on this line by itself.
I've attached an image of the issue, and the savegame file.
Re: ChooChoo, a train network AI
Hi, this happened and I saw that it said to post the error here. I am a 100% newb to the forum and I 100% do not know how to play this game, I just love the game and have done for many many years, learning the actual rules never interested me as much as making a map and enjoying watching the cities grow (with cheats). So I apologise if this had been posted or it's a waste of time or an obvious problem. I simply just play the game to build cities and love to build roads and such and your AI is a perfect accompaniment to my map building enjoyment. I hope this helps and thank you for the AI. (See attached photo, If I managed to attach it correctly that is).
- Attachments
-
- Screenshot 2023-06-16 at 23.58.45.png
- (1.02 MiB) Not downloaded yet
-
- Route Supervisor
- Posts: 466
- Joined: 15 Jun 2007 09:27
- Skype: madchimiste
- Location: Berlin, Deutschland
Re: ChooChoo, a train network AI
Hello BenArt86, and welcome to the forums.
As stated on the error message, you are missing a library that ChooChoo uses. It is the Pathfinder.Road version 3.
You can download it via the online content on the title screen:
Re: ChooChoo, a train network AI
Thanks for jumping in @arikover! Hopefully that helped BenArt86 out 
Still, I think OpenTTD should have automatically installed the dependency along with the AI, so I will check if maybe I misconfigured something in the last updates.
Edit: yes, looked like that either got lost in an update, or maybe it was never there and my AI was just tagging along on the library downloaded by/for another AI. Should be fixed now!

Still, I think OpenTTD should have automatically installed the dependency along with the AI, so I will check if maybe I misconfigured something in the last updates.
Edit: yes, looked like that either got lost in an update, or maybe it was never there and my AI was just tagging along on the library downloaded by/for another AI. Should be fixed now!
Re: ChooChoo, a train network AI
This AI assumes that MAIL exists as a cargo, and will crash if it does not exist.
He's like, some kind of OpenTTD developer.
Re: ChooChoo, a train network AI
Thanks for the bug report! Fixed in the latest versionpeter1138 wrote: 13 Feb 2024 11:43 This AI assumes that MAIL exists as a cargo, and will crash if it does not exist.

- Captain Rand
- Traffic Manager
- Posts: 205
- Joined: 28 Jan 2012 07:35
Re: ChooChoo, a train network AI
Hi Michiel,
I have a feature request/suggestion.
As programmed, ChooChoo has trains running on the right on double tracks. Would it be possible to add a parameter to have them running on the left? Is this possible?
I love ChooChoo, and always have multiple instances running in my games. I use Infrastructure sharing and your AI helps me build some awesome networks.
Many thanks,
Pete.
I have a feature request/suggestion.
As programmed, ChooChoo has trains running on the right on double tracks. Would it be possible to add a parameter to have them running on the left? Is this possible?
I love ChooChoo, and always have multiple instances running in my games. I use Infrastructure sharing and your AI helps me build some awesome networks.
Many thanks,
Pete.
There's nothing like a deadline to hone the concentration.
Good manners cost nothing, but earn respect.
" 'Impossible' is not in our vocabulary." Jack Chrichton, Farscape
Good manners cost nothing, but earn respect.
" 'Impossible' is not in our vocabulary." Jack Chrichton, Farscape
Re: ChooChoo, a train network AI
Thanks Pete! Apart from the occasional bug report I have really no way of knowing if people still use these AIs, so that's great to hear
As for your request... I'm Dutch, and we drive on the right side, so everything else is the wrong side
Theoretically the code should be able to support swapping sides fairly easily, but that could lead to some interesting bugs... I'll think about it

As for your request... I'm Dutch, and we drive on the right side, so everything else is the wrong side

Theoretically the code should be able to support swapping sides fairly easily, but that could lead to some interesting bugs... I'll think about it

- Captain Rand
- Traffic Manager
- Posts: 205
- Joined: 28 Jan 2012 07:35
Re: ChooChoo, a train network AI
I'm English. We drive on the left, which is right. You're driving on the right, which is wrong......
*Cough* .... Moving on....
What I'm suggesting is a parameter setting for when the AI first starts. Building it's tracks either left or right driving from when it first spawns. this shouldn't be swappable after the AI starts.
Hope this makes sense, I feel I'm not explaining it very well.
Pete.

*Cough* .... Moving on....
What I'm suggesting is a parameter setting for when the AI first starts. Building it's tracks either left or right driving from when it first spawns. this shouldn't be swappable after the AI starts.
Hope this makes sense, I feel I'm not explaining it very well.
Pete.
There's nothing like a deadline to hone the concentration.
Good manners cost nothing, but earn respect.
" 'Impossible' is not in our vocabulary." Jack Chrichton, Farscape
Good manners cost nothing, but earn respect.
" 'Impossible' is not in our vocabulary." Jack Chrichton, Farscape
Re: ChooChoo, a train network AI

> Hope this makes sense, I feel I'm not explaining it very well.
No worries, perfectly clear

For Choo Choo, the choice for driving on the left or right would be locked in per network, so you could even change the setting during a game, and then future networks would take that into account.
- Captain Rand
- Traffic Manager
- Posts: 205
- Joined: 28 Jan 2012 07:35
Re: ChooChoo, a train network AI
Yes, this is exactly what I mean.Michiel wrote: 01 Mar 2024 18:09 For Choo Choo, the choice for driving on the left or right would be locked in per network,
Pete.
There's nothing like a deadline to hone the concentration.
Good manners cost nothing, but earn respect.
" 'Impossible' is not in our vocabulary." Jack Chrichton, Farscape
Good manners cost nothing, but earn respect.
" 'Impossible' is not in our vocabulary." Jack Chrichton, Farscape
Re: ChooChoo, a train network AI
By popular request (hi Pete!) ChooChoo now also supports left hand traffic on double tracks!
The default setting is now to use the same drive side as road traffic (as set in game options) but you can also force it to left or right hand traffic. If you change the setting during a game, it'll take effect when ChooChoo starts a new rail network.
The default setting is now to use the same drive side as road traffic (as set in game options) but you can also force it to left or right hand traffic. If you change the setting during a game, it'll take effect when ChooChoo starts a new rail network.
Who is online
Users browsing this forum: No registered users and 5 guests