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: 338
Joined: 13 Jul 2008 00:57
Contact:

Re: ChooChoo, a train network AI

Post by Michiel »

Noted, and thanks! I'll try and get a new version out before 1.2 is out of beta (but no promises).
Alberth
OpenTTD Developer
OpenTTD Developer
Posts: 4763
Joined: 09 Sep 2007 05:03
Location: home

Re: ChooChoo, a train network AI

Post by Alberth »

The fix by soravux is correct, but there is a simpler way to get the result:

Code: Select all

function CompareRouteValue(a, b) {
   return a.payback - b.payback;
}
Michiel wrote:Noted, and thanks! I'll try and get a new version out before 1.2 is out of beta (but no promises).
You better climb in your time machine then, as 1.2.0-RC1 was released two days ago :)
User avatar
Michiel
Transport Coordinator
Transport Coordinator
Posts: 338
Joined: 13 Jul 2008 00:57
Contact:

Re: ChooChoo, a train network AI

Post by Michiel »

Alberth wrote:
Michiel wrote:Noted, and thanks! I'll try and get a new version out before 1.2 is out of beta (but no promises).
You better climb in your time machine then, as 1.2.0-RC1 was released two days ago :)
LOL, well bugger :) Sorry folks, it's gonna be late!
User avatar
Michiel
Transport Coordinator
Transport Coordinator
Posts: 338
Joined: 13 Jul 2008 00:57
Contact:

Re: ChooChoo, a train network AI

Post by Michiel »

Alberth wrote:The fix by soravux is correct, but there is a simpler way to get the result:

Code: Select all

function CompareRouteValue(a, b) {
   return a.payback - b.payback;
}
Lemme think... Is that also correct when a.payback - b.payback overflows? Not likely to happen here, I know, but in the general case. I think it is, but I have a nagging feeling I remember reading about having to do the less/greater than check to catch some edge case.
Alberth
OpenTTD Developer
OpenTTD Developer
Posts: 4763
Joined: 09 Sep 2007 05:03
Location: home

Re: ChooChoo, a train network AI

Post by Alberth »

Good point, that may indeed cause trouble.
DeletedUser17
Engineer
Engineer
Posts: 47
Joined: 15 Mar 2012 23:48

Re: ChooChoo, a train network AI

Post by DeletedUser17 »

Regardless of problems, looks very, very nice! And besides, what AI isn't riddled with hidden problems? This is really one of the best I've ever seen :D
User avatar
Michiel
Transport Coordinator
Transport Coordinator
Posts: 338
Joined: 13 Jul 2008 00:57
Contact:

Re: ChooChoo, a train network AI

Post by Michiel »

billybobjoepants wrote:Regardless of problems, looks very, very nice! And besides, what AI isn't riddled with hidden problems? This is really one of the best I've ever seen :D
Thank you :D
User avatar
Michiel
Transport Coordinator
Transport Coordinator
Posts: 338
Joined: 13 Jul 2008 00:57
Contact:

Re: ChooChoo, a train network AI

Post by Michiel »

Fixing bugs and taking names... Currently testing a new release, with several fixes:
- handle maps with no/few 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

At the moment I'm watching a test run where it seems to be quite happily wiring up the northern quadrant of a 1024x1024 map into a single sprawling rail network, so it's looking good, so far :)
Attachments
big-network.png
big-network.png (66.79 KiB) Viewed 7794 times
MAG101
Engineer
Engineer
Posts: 28
Joined: 14 Dec 2011 00:55

Re: ChooChoo, a train network AI

Post by MAG101 »

are you working on fixing the limited features?

sorry my bad english :oops:

Limited load/save support (it'll "forget" the current work in progress). :cry:
No train replacement except autorenew, but it will switch to new rail types when it starts a new network. :cry:

Ideas :idea:

1. Full Save and Load that Choo Choo will conuting train line that saved than forgot the work in Progress

2. Switching new englines First Steam Train to Asiastar than Autorenewing the trains.

3. Remove unused Cargo lines and any parts of unused tracks and station and even remove full network if no trains running them, Infrastructure maintenance and Inflation + no train running = network money losing!
User avatar
Michiel
Transport Coordinator
Transport Coordinator
Posts: 338
Joined: 13 Jul 2008 00:57
Contact:

Re: ChooChoo, a train network AI

Post by Michiel »

1. Full Save and Load that Choo Choo will conuting train line that saved than forgot the work in Progress
Probably not for a while. You'd have to save a LOT of state to remember "where you left off". However, it may be possible to either store, or detect, open ended crossings and resume expansion from those... Hmm, I'll keep it in mind!
Switching new englines First Steam Train to Asiastar than Autorenewing the trains.
Probably not, I tend to put off those boring "management" tasks and focus on the network building. It could perform much, much better if I did some more train management... but I just don't care enough :) The goal for ChooChoo isn't to be the most efficient competitor, but to build stuff that looks interesting, after all. But more efficiency does let you build more stuff...
Remove unused Cargo lines and any parts of unused tracks and station and even remove full network if no trains running them, Infrastructure maintenance and Inflation + no train running = network money losing!
I'll go with "maybe". Station maintenance is really cheap and unused rail is free, so it's easier to just let it rust... but I admit that there's an aesthetic reason for cleaning up unused stuff, so I might, at some point.

After the bug fixes, I've got some plans to let it try harder to find sites to build stations, so it can grow even bigger networks. Then, I want to look at running freight trains, as well.
User avatar
Michiel
Transport Coordinator
Transport Coordinator
Posts: 338
Joined: 13 Jul 2008 00:57
Contact:

Re: ChooChoo, a train network AI

Post by Michiel »

Update uploaded to Bananas!
User avatar
Michiel
Transport Coordinator
Transport Coordinator
Posts: 338
Joined: 13 Jul 2008 00:57
Contact:

Re: ChooChoo, a train network AI

Post by Michiel »

Woops, and already found the first new bug... messed up the cargo route selection. Currently (finally!) migrating to the new API version, so I'll upload a fixed one once things are working again.

Edit: new version is up.
KaosKidd
Engineer
Engineer
Posts: 1
Joined: 24 Apr 2012 13:10

Re: ChooChoo, a train network AI

Post by KaosKidd »

Hello everyone.
Michiel, I wanted to say that your AI is awesome! I started and played a full game last night and found it fascinating to watch. With only one or twice did I find an depot with a train not attached to anything. I wasn't paying close enough attention to give you any details.

Anyway, my first post and it's about your AI. Great Job, please keep on working on it!

KaosKidd
Thanks,

KaosKidd
I hope this helps. I can always tell the time but I can't always make a clock.
User avatar
Michiel
Transport Coordinator
Transport Coordinator
Posts: 338
Joined: 13 Jul 2008 00:57
Contact:

Re: ChooChoo, a train network AI

Post by Michiel »

Thanks :D I'll keep an eye out for what you saw, see if I can fix it.
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: ChooChoo, a train network AI

Post by planetmaker »

Mis-placed bug-report for choochoo: http://bugs.openttd.org/task/5265
User avatar
Michiel
Transport Coordinator
Transport Coordinator
Posts: 338
Joined: 13 Jul 2008 00:57
Contact:

Re: ChooChoo, a train network AI

Post by Michiel »

Thanks - looks like that's the old version, that bug should be fixed already.
gobbybobby
Engineer
Engineer
Posts: 7
Joined: 20 Mar 2012 22:33

Re: ChooChoo, a train network AI

Post by gobbybobby »

starting in 1900 using a couple of train packs that include some monorail with "underground/ metro" style trains

The AI is building monorail tracks, and losing money as these slow, and expensive to run trains are no good for the longer routes its building, (I am on largest map size, with just 50 citys as I like city's to be spread out) and just going out of business each time it starts up. I have another AI using trains, which is coping fine building normal steam trains, connecting industry. Maybe this AI should not jump to monorail just because it can!


Its now connected 2 city' and is just breaking even in terms of train income. (making about £2,000 per train per year, so going negative on property maintenance and lone interest.) Took it till 1922 to finally get a train to make profit, but its still gonna fail in 10 years if it keeps going how it is!
User avatar
Michiel
Transport Coordinator
Transport Coordinator
Posts: 338
Joined: 13 Jul 2008 00:57
Contact:

Re: ChooChoo, a train network AI

Post by Michiel »

I understand the problem, but I'm not really able to support all kinds of newgrfs. ChooChoo just assumes that the most recent rail type is the best available, as it is in the normal game. It has no way to tell that in your game, monorail is actually metro track. It would need quite an elaborate mathematical model to be able to work out what the best train/track combination would be. It's definitely possible, but I'm pretty sure I'm not going to ;) Thanks for reporting it though, I do appreciate the feedback!
mabono5
Engineer
Engineer
Posts: 5
Joined: 12 Mar 2010 16:51

Re: ChooChoo, a train network AI

Post by mabono5 »

Hey! Great AI, one of my faves.

I do use several types of grf's to make that game more interesting, but ChooChoo does not seem to want to play any more. It starts to build a network, connects the station's, but immediately removes what it has built, leaving a train in a depot to rust.

It builds a Millenium Z1 Electric train then an error saying "no suitable wagon" is in the debug.

Any ideas?

Thanks
Steve
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: ChooChoo, a train network AI

Post by Zuu »

mabono5 wrote:Hey! Great AI, one of my faves.

I do use several types of grf's to make that game more interesting, but ChooChoo does not seem to want to play any more. It starts to build a network, connects the station's, but immediately removes what it has built, leaving a train in a depot to rust.

It builds a Millenium Z1 Electric train then an error saying "no suitable wagon" is in the debug.

Any ideas?

Thanks
Steve
You might want to provide a list of NewGRFs to make it easier to figure out what have gone wrong in your case. The engine name sounds like you play with the NUTS train set, but I don't know for sure.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 12 guests