ChooChoo, a train network AI

Discuss the new AI features ("NoAI") introduced into OpenTTD 0.7, allowing you to implement custom AIs, and the new Game Scripts available in OpenTTD 1.2 and higher.

Moderator: OpenTTD Developers

User avatar
Michiel
Transport Coordinator
Transport Coordinator
Posts: 339
Joined: 13 Jul 2008 00:57
Contact:

Re: ChooChoo, a train network AI

Post by Michiel »

Thank you! I already stole some of the best bits :wink: I'll probably make a new release in a few days.
User avatar
Michiel
Transport Coordinator
Transport Coordinator
Posts: 339
Joined: 13 Jul 2008 00:57
Contact:

Re: ChooChoo, a train network AI

Post by Michiel »

New version! An actual update and not just a bug fix this time 8o

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! :D 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.
bridges-squeeze-cropped.png
bridges-squeeze-cropped.png (771.23 KiB) Viewed 6463 times
bridges3-after.png
bridges3-after.png (701.12 KiB) Viewed 6463 times
Snake like a snaky snake!
snake.png
snake.png (1.43 MiB) Viewed 6462 times
User avatar
Michiel
Transport Coordinator
Transport Coordinator
Posts: 339
Joined: 13 Jul 2008 00:57
Contact:

Re: ChooChoo, a train network AI

Post by Michiel »

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:
  • 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.
User avatar
Redirect Left
Tycoon
Tycoon
Posts: 7249
Joined: 22 Jan 2005 19:31
Location: Wakefield, West Yorkshire

Re: ChooChoo, a train network AI

Post by Redirect Left »

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.
Attachments
CC oops image.png
(708.08 KiB) Not downloaded yet
CC Oops.sav
(2.68 MiB) Downloaded 70 times
Image
Need some good tested AI? - Unofficial AI Tester, list of good stuff & thread is here.
User avatar
Michiel
Transport Coordinator
Transport Coordinator
Posts: 339
Joined: 13 Jul 2008 00:57
Contact:

Re: ChooChoo, a train network AI

Post by Michiel »

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!
User avatar
Redirect Left
Tycoon
Tycoon
Posts: 7249
Joined: 22 Jan 2005 19:31
Location: Wakefield, West Yorkshire

Re: ChooChoo, a train network AI

Post by Redirect Left »

Michiel wrote: 31 May 2023 12:32 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!
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?
2023-05-31 13_43_10-OpenTTD 13.1.png
2023-05-31 13_43_10-OpenTTD 13.1.png (47.49 KiB) Viewed 6262 times
Image
Need some good tested AI? - Unofficial AI Tester, list of good stuff & thread is here.
User avatar
Michiel
Transport Coordinator
Transport Coordinator
Posts: 339
Joined: 13 Jul 2008 00:57
Contact:

Re: ChooChoo, a train network AI

Post by Michiel »

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.
User avatar
Michiel
Transport Coordinator
Transport Coordinator
Posts: 339
Joined: 13 Jul 2008 00:57
Contact:

Re: ChooChoo, a train network AI

Post by Michiel »

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.
User avatar
Michiel
Transport Coordinator
Transport Coordinator
Posts: 339
Joined: 13 Jul 2008 00:57
Contact:

Re: ChooChoo, a train network AI

Post by Michiel »

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.
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.
BenArt86
Engineer
Engineer
Posts: 1
Joined: 16 Jun 2023 23:06

Re: ChooChoo, a train network AI

Post by BenArt86 »

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
arikover
Route Supervisor
Route Supervisor
Posts: 466
Joined: 15 Jun 2007 09:27
Skype: madchimiste
Location: Berlin, Deutschland

Re: ChooChoo, a train network AI

Post by arikover »

BenArt86 wrote: 16 Jun 2023 23:16 Hi, this happened and I saw that it said to post the error here.
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:
Online_Content.png
Online_Content.png (354.29 KiB) Viewed 6085 times
Pathfinder.png
Pathfinder.png (1.11 MiB) Viewed 6085 times
User avatar
Michiel
Transport Coordinator
Transport Coordinator
Posts: 339
Joined: 13 Jul 2008 00:57
Contact:

Re: ChooChoo, a train network AI

Post by Michiel »

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!
peter1138
OpenTTD Developer
OpenTTD Developer
Posts: 1732
Joined: 30 Mar 2005 09:43

Re: ChooChoo, a train network AI

Post by peter1138 »

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.
User avatar
Michiel
Transport Coordinator
Transport Coordinator
Posts: 339
Joined: 13 Jul 2008 00:57
Contact:

Re: ChooChoo, a train network AI

Post by Michiel »

peter1138 wrote: 13 Feb 2024 11:43 This AI assumes that MAIL exists as a cargo, and will crash if it does not exist.
Thanks for the bug report! Fixed in the latest version :)
User avatar
Captain Rand
Traffic Manager
Traffic Manager
Posts: 192
Joined: 28 Jan 2012 07:35

Re: ChooChoo, a train network AI

Post by Captain Rand »

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.
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
User avatar
Michiel
Transport Coordinator
Transport Coordinator
Posts: 339
Joined: 13 Jul 2008 00:57
Contact:

Re: ChooChoo, a train network AI

Post by Michiel »

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 :D

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 :)
User avatar
Captain Rand
Traffic Manager
Traffic Manager
Posts: 192
Joined: 28 Jan 2012 07:35

Re: ChooChoo, a train network AI

Post by Captain Rand »

I'm English. We drive on the left, which is right. You're driving on the right, which is wrong...... :D
*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
User avatar
Michiel
Transport Coordinator
Transport Coordinator
Posts: 339
Joined: 13 Jul 2008 00:57
Contact:

Re: ChooChoo, a train network AI

Post by Michiel »

:lol:

> 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.
User avatar
Captain Rand
Traffic Manager
Traffic Manager
Posts: 192
Joined: 28 Jan 2012 07:35

Re: ChooChoo, a train network AI

Post by Captain Rand »

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,
Yes, this is exactly what I mean.

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
User avatar
Michiel
Transport Coordinator
Transport Coordinator
Posts: 339
Joined: 13 Jul 2008 00:57
Contact:

Re: ChooChoo, a train network AI

Post by Michiel »

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.
left-hand.png
left-hand.png (441.48 KiB) Viewed 1992 times
traffic-side-settings.png
traffic-side-settings.png (8.33 KiB) Viewed 1992 times
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 15 guests