Denver & Rio Grande train AI (A freight train 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

Post Reply
User avatar
Dustin
Transport Coordinator
Transport Coordinator
Posts: 272
Joined: 07 Dec 2005 19:22

Re: Denver & Rio Grande train AI (A freight train AI)

Post by Dustin »

SirkoZ wrote:Roujin - if you read the beginning of this thread - you'll see that the name is AI's correct/intended as Dustin will confirm, I'm sure.

Anyhow - no more _1_ observed in R13, just some passing problems as Roujin described. There was also a case when I think it couldn't build a passing lane further and it built signals on the rail connecting two passing lanes. This no doubt cause a big jam with 4 trains on that route what with path signals, their reserved tracks and all. :-)
That's a bug. I haven't noticed it making signals outside the passing lanes. It's because of the switchback. When it builds signals it looks for the tile closest to the passing lane signal to do it. In the case of a switchback like this, things can go wrong. Hmmm. Not sure how to fix that without doing a ton more work on passing lanes.
Brumi
President
President
Posts: 921
Joined: 18 Jul 2009 17:54

Re: Denver & Rio Grande train AI (A freight train AI)

Post by Brumi »

Hi Dustin,
I'm testing RC13, but it seems that the number 13 is not so lucky now. :(
The Ant pathfinder became weaker (probably due to some bug), it even failed here: (it was deleting the crow signs when I took the screenshot)
antfailing.png
antfailing.png (44.72 KiB) Viewed 4228 times
And if the AI manages to build a route, it gets into some kind of infinite loop. It 'forgets' to remove the signs, doesn't build the passing lane, and does nothing afterwards. All activity I see is that it borrows money to the limit, and then repays the loan gradually until it runs out of money. Then it borrows again, and the process continues...
RC13 problem.png
RC13 problem.png (168.87 KiB) Viewed 1765 times
I hope you will be able to fix it (without trying 3 times) :)
Roujin
Tycoon
Tycoon
Posts: 1884
Joined: 08 Apr 2007 04:07

Re: Denver & Rio Grande train AI (A freight train AI)

Post by Roujin »

Ahh, so the 'technical' name of your AI is DustinAI, whereas its ingame name will be one of a choice of realistic-ish names like "Denver & Rio Grande", "Denver & Santa Fe" and so on? That's actually quite nice. :) But I'd rename this thread to DustinAI then.
* @Belugas wonders what is worst... a mom or a wife...
<Lakie> Well, they do the same thing but the code is different.

______________
My patches
check my wiki page (sticky button) for a complete list

ImageImage
ImageImageImageImageImageImageImage
User avatar
SirkoZ
Tycoon
Tycoon
Posts: 1518
Joined: 06 Mar 2004 23:51
Location: The sunny side of Alps

Re: Denver & Rio Grande train AI (A freight train AI)

Post by SirkoZ »

Roujin - I think people who are seriously interested in this AI can deduce that it's DustinAI... :-)
User avatar
Dustin
Transport Coordinator
Transport Coordinator
Posts: 272
Joined: 07 Dec 2005 19:22

Re: Denver & Rio Grande train AI (A freight train AI)

Post by Dustin »

Brumi wrote:Hi Dustin,
I'm testing RC13, but it seems that the number 13 is not so lucky now. :(
The Ant pathfinder became weaker (probably due to some bug), it even failed here: (it was deleting the crow signs when I took the screenshot)
antfailing.png
And if the AI manages to build a route, it gets into some kind of infinite loop. It 'forgets' to remove the signs, doesn't build the passing lane, and does nothing afterwards. All activity I see is that it borrows money to the limit, and then repays the loan gradually until it runs out of money. Then it borrows again, and the process continues...
RC13 problem.png
I hope you will be able to fix it (without trying 3 times) :)
Interesting. There is basically no way the ant should have failed there. That's a bad bug then.

It seems some of the "fixes" I tried to make for 2cc destabilized the code pretty badly. :(
User avatar
Dustin
Transport Coordinator
Transport Coordinator
Posts: 272
Joined: 07 Dec 2005 19:22

Re: Denver & Rio Grande train AI (A freight train AI)

Post by Dustin »

Roujin wrote:Ahh, so the 'technical' name of your AI is DustinAI, whereas its ingame name will be one of a choice of realistic-ish names like "Denver & Rio Grande", "Denver & Santa Fe" and so on? That's actually quite nice. :) But I'd rename this thread to DustinAI then.
You could say it that way. Only I would say the "Official" name is "Denver & Rio Grande". The technical or code name is "DustinAI". The in game names are not "realistic-ish". They are historic and painstaking researched in 20 minutes of internet surfing. So there. :D

If I change anything, it will be to take "Dustin" our and replace it with "D&RG".
User avatar
Michiel
Transport Coordinator
Transport Coordinator
Posts: 339
Joined: 13 Jul 2008 00:57
Contact:

Re: Denver & Rio Grande train AI (A freight train AI)

Post by Michiel »

I think yours is one of the best sounding AI names so far, so don't change it :D
Roujin
Tycoon
Tycoon
Posts: 1884
Joined: 08 Apr 2007 04:07

Re: Denver & Rio Grande train AI (A freight train AI)

Post by Roujin »

Err.. just do the naming like you want to - if I somehow stepped on your toes, I am sorry :oops: I didn't intend to.
* @Belugas wonders what is worst... a mom or a wife...
<Lakie> Well, they do the same thing but the code is different.

______________
My patches
check my wiki page (sticky button) for a complete list

ImageImage
ImageImageImageImageImageImageImage
User avatar
Dustin
Transport Coordinator
Transport Coordinator
Posts: 272
Joined: 07 Dec 2005 19:22

Re: Denver & Rio Grande train AI (A freight train AI)

Post by Dustin »

Roujin wrote:Err.. just do the naming like you want to - if I somehow stepped on your toes, I am sorry :oops: I didn't intend to.
No worries mate! You actually had a good point. Check 14.beta for the changes. :)
User avatar
SirkoZ
Tycoon
Tycoon
Posts: 1518
Joined: 06 Mar 2004 23:51
Location: The sunny side of Alps

Re: Denver & Rio Grande train AI (A freight train AI)

Post by SirkoZ »

Dustin - please don't zip the .tar - it's redundant.

EDIT: Continuing - R14.1 bug report (r17064, no .grfs):
Well - I can't help but mention the square but now it went horribly wrong - looks like it started flattening a sea-level tile and the AI flattened a stretch through my map (512x256), quite curious. :-)
It even flooded some of its own trains...Here's the screenie (a director's cut):
pic
pic
D14-1_flood-forming.png (11.54 KiB) Viewed 3995 times
.

And flooding in minimap view:
pic
pic
D14-1_flood-forming_minimap.png (15.83 KiB) Viewed 3996 times
.

Next bug or so would be the signs - lots of them along the mainline (not along passing line) although I had signs switched off:
pic
pic
D14-1_signs.png (31.12 KiB) Viewed 3996 times
.
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: Denver & Rio Grande train AI (A freight train AI)

Post by Zuu »

SirkoZ wrote:Dustin - please don't zip the .tar - it's redundant.
It is true that both zip and tar are containing formats that may contain multiple files inside. However only zip (optionally) compress the files contained in the archive. Tar on the other hand do not do any compression what so ever.

That said, the tar archives for AIs are generally not really that big that they need to be compressed. And unpacking the zip-layer adds extra work on the receiver side, especially for GUI users. So I think it is not necessary to zip the tars, even though tar files are not compressed.


Sorry, I don't have anything to add related to the AI. I keep following the progress of the AI though.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Brumi
President
President
Posts: 921
Joined: 18 Jul 2009 17:54

Re: Denver & Rio Grande train AI (A freight train AI)

Post by Brumi »

Hi Dustin,
I've been testing RC14 beta. It seems there is some serious development going on... :)
So I start with a minor bug (this really shouldn't take days to fix :mrgreen: ): company name is 'Denver & Rio Grand', the 'e' was omitted.
I wondered why RC13 was working so poorly for me (and there were similar symptoms for RC14 beta as well), so I tried your AI with Roujin's openttd.cfg file he used for his tournament. It turned out that my problem is that I use smaller and rougher maps, and most importantly, I don't use realistic acceleration. This makes things harder for D&RG, and it waits MUCH more for money. But even with that, I think it should be able to put up at least 2 rail routes...
Here are the screenshots I took:
In the first one the problem is that it didn't continue the passing lane after the town, leaving about half of the way without a passing lane.
passinglane.png
passinglane.png (132.99 KiB) Viewed 3982 times
Here it stopped building the rail, started placing this new type of signs, and then it deleted the rail back. I saw a line in the AI debug window, saying something like this: 'building stopped: AREA_NOT_CLEAR'. There was no other AI present, at I didn't build anything either. I don't remember that there were any new industries. I forgot to check if the AI ran out of money...
deletingrail.png
deletingrail.png (79.25 KiB) Viewed 3981 times
It's very good that the passing lanes are now connected to the stations.
Anyway, is there any progress with Bee and Seagull? (not urging you, just curious :) )
User avatar
Dustin
Transport Coordinator
Transport Coordinator
Posts: 272
Joined: 07 Dec 2005 19:22

Re: Denver & Rio Grande train AI (A freight train AI)

Post by Dustin »

SirkoZ wrote:Dustin - please don't zip the .tar - it's redundant.
I have too, otherwise I can't upload the file with my terrible internet connection. This site times out when I try to upload as little as 100KB. Sorry for the inconvience. I could use FTP to upload the files to my webhost, but the custom here is to upload to the board directly.

EDIT: Continuing - R14.1 bug report (r17064, no .grfs):
Well - I can't help but mention the square but now it went horribly wrong - looks like it started flattening a sea-level tile and the AI flattened a stretch through my map (512x256), quite curious. :-)
It even flooded some of its own trains...Here's the screenie (a director's cut):
D14-1_flood-forming.png
.
I saw that once before. It's because the tiles wrap around when I use

Code: Select all

AITile.GetIndex(deltaX, deltaY) + IndustryTile;
the underlying tiles are just Ints so things go wrong at the map edge. I know how to fix it now thanks.
Next bug or so would be the signs - lots of them along the mainline (not along passing line) although I had signs switched off:
D14-1_signs.png
.
Yeah, that's a "feature" of the beta so I could see what's going on more clearly with passing lanes.
User avatar
Dustin
Transport Coordinator
Transport Coordinator
Posts: 272
Joined: 07 Dec 2005 19:22

Re: Denver & Rio Grande train AI (A freight train AI)

Post by Dustin »

Brumi wrote:Hi Dustin,
I've been testing RC14 beta. It seems there is some serious development going on... :)
So I start with a minor bug (this really shouldn't take days to fix :mrgreen: ): company name is 'Denver & Rio Grand', the 'e' was omitted.
Ohh, thanks for catching that!
I wondered why RC13 was working so poorly for me (and there were similar symptoms for RC14 beta as well), so I tried your AI with Roujin's openttd.cfg file he used for his tournament. It turned out that my problem is that I use smaller and rougher maps, and most importantly, I don't use realistic acceleration. This makes things harder for D&RG, and it waits MUCH more for money. But even with that, I think it should be able to put up at least 2 rail routes...
Adding the ability to do well in harsher scenerios is something for later I think. The recent more robust support for 2cc should keep the AI from going bankrupt as often in those conditions at least. One thing I could do is lower the min-distance for links. Currently it's about 50 tiles. So once it explores all the 50+ tile options it could consider shorter routes.
Here are the screenshots I took:
In the first one the problem is that it didn't continue the passing lane after the town, leaving about half of the way without a passing lane.
Passing lanes are one of the things under development right now. I know that I am having problems sometimes not adding all the lanes I could.

Here it stopped building the rail, started placing this new type of signs, and then it deleted the rail back. I saw a line in the AI debug window, saying something like this: 'building stopped: AREA_NOT_CLEAR'. There was no other AI present, at I didn't build anything either. I don't remember that there were any new industries. I forgot to check if the AI ran out of money...
This is a bug in the new bridge code. Thanks for the report. That screenshot really makes it clear what went wrong. On the plus side, the AI tried to bridge that rail.

It's very good that the passing lanes are now connected to the stations.
Anyway, is there any progress with Bee and Seagull? (not urging you, just curious :) )
Nothing codewise yet. I keep thinking about them. Right now bridge is the place that needs work. If crow path is diagonal, you will never get a bridge. And that's more than half the cases when crossing other roads and rails.
User avatar
Dustin
Transport Coordinator
Transport Coordinator
Posts: 272
Joined: 07 Dec 2005 19:22

Re: Denver & Rio Grande train AI (A freight train AI)

Post by Dustin »

RC14 beta2 is posted to main post. Enjoy.
Brumi
President
President
Posts: 921
Joined: 18 Jul 2009 17:54

Re: Denver & Rio Grande train AI (A freight train AI)

Post by Brumi »

Hi Dustin,
Nice work! :bow:
I'm glad to see that the pathfinder is MUCH stronger now.
My only problem so far that I think D&RG is still too harsh with its own budget, I think it should be able to set up at least two routes with a 500k starting loan without seeing 'Build Route Waiting for more money...' in the AI Debug window. I'm in 1953 while writing this, and Denver & Rio Grande (started in 1950) has just started to build its second line.
And I have one little suggestion, it's quite useless, so ignore it if coding it needs a lot of work:
I think the order of the additional company names should be randomized, because it's not very probable that someone will start 14 DustinAIs in one game. It's OK that the first one is always 'Denver & Rio Grande', only the others should be randomised.
Nice work again! :)
User avatar
Dustin
Transport Coordinator
Transport Coordinator
Posts: 272
Joined: 07 Dec 2005 19:22

Re: Denver & Rio Grande train AI (A freight train AI)

Post by Dustin »

Brumi wrote:Hi Dustin,
Nice work! :bow:
I'm glad to see that the pathfinder is MUCH stronger now.
My only problem so far that I think D&RG is still too harsh with its own budget, I think it should be able to set up at least two routes with a 500k starting loan without seeing 'Build Route Waiting for more money...' in the AI Debug window. I'm in 1953 while writing this, and Denver & Rio Grande (started in 1950) has just started to build its second line.
And I have one little suggestion, it's quite useless, so ignore it if coding it needs a lot of work:
I think the order of the additional company names should be randomized, because it's not very probable that someone will start 14 DustinAIs in one game. It's OK that the first one is always 'Denver & Rio Grande', only the others should be randomised.
Nice work again! :)
try the 2cc set. You will think it's not harsh enough!

hmm, random names. I wonder if that would confusing...

edit: I decided that I should add some settings based on these suggestions. Random names will come later as an option.

Edit: Stronger pathfinder? Just based on the new bridges and passing lanes? I might have fixed some other bugs along the way, but it's basically the same.
Last edited by Dustin on 11 Aug 2009 04:50, edited 1 time in total.
User avatar
Dustin
Transport Coordinator
Transport Coordinator
Posts: 272
Joined: 07 Dec 2005 19:22

Re: Denver & Rio Grande train AI (A freight train AI)

Post by Dustin »

RC15 posted. Enjoy.

Known issue: Level tiles problem near map edge. Its been in there for a while, but now the fix is known. Just waiting to stabilize new functionality before tackling it.

Edit: I should have gone to bed, but I added some fixes and posted an RC16. I think we are close to a V1 here.
Brumi
President
President
Posts: 921
Joined: 18 Jul 2009 17:54

Re: Denver & Rio Grande train AI (A freight train AI)

Post by Brumi »

Hi Dustin,
Testing RC16... I agree that you're getting closer and closer to V1 :)
What I meant under the 'stronger pathfinder' was that its success rate is higher than it was in the previous versions.
There seems to be a problem when choosing the consumer industry. I see this very often:
D&RG problem.png
D&RG problem.png (11.89 KiB) Viewed 3668 times
The AI checked almost all industries, and there is something that it doesn't like. The result is:
D&RG problem #2.png
D&RG problem #2.png (320.68 KiB) Viewed 1734 times
It might be the case that the red player was only unlucky. Just for the facts, I was running two DustinAIs (the yellow one with the maximum fiscal restraint, the red one with the minimum fiscal restraint) on a 512x512, flat, very smooth map with a normal amount of towns and a high amount of industries. The maximum loan was 500k pounds.
And one little thing, you forgot to correct the 'Denver & Rio Grand' typo.
Good luck in your further work!
Brumi
President
President
Posts: 921
Joined: 18 Jul 2009 17:54

Re: Denver & Rio Grande train AI (A freight train AI)

Post by Brumi »

The same game is still running, and I encountered this:
passinglane.png
passinglane.png (51.13 KiB) Viewed 3653 times
The trains can't get back to the producer station because of the one-way signals.
Anyway, both companies are doing nicely, and it seems that with the default train set a lower fiscal restraint is much better.
EDIT: about the random names, I didn't mean the random generation of them, I really like the concept with the historical railway lines, I intended to say that only the ORDER of them should be randomized. I'm saying this because then it's quite improbable that the 'Colorado Kansas & Oklahoma' will appear in the game. Sorry for any misunderstanding.
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 10 guests