Denver & Rio Grande train AI (A freight train AI)
Moderator: OpenTTD Developers
- planetmaker
- OpenTTD Developer
- Posts: 9432
- Joined: 07 Nov 2007 22:44
- Location: Sol d
Re: Denver & Rio Grande train AI (A freight train AI)
well... isn't "forbid 90° turns = on" the default setting?
OpenTTD: manual | online content | translations | Wanted contributions and patches
#openttdcoop: blog | wiki | public server | DevZone | NewGRF web translator
DevZone - home of the free NewGRFs: OpenSFX | OpenMSX | OpenGFX | Swedish Rails | OpenGFX+ Trains|RV|Industries|Airports|Landscape | NML
Re: Denver & Rio Grande train AI (A freight train AI)
Nope, it is off by default. But it is one of the first things I do turn on at a new OpenTTD configuration.planetmaker wrote:well... isn't "forbid 90° turns = on" the default setting?
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Junctioneer (a traffic intersection simulator)
Re: Denver & Rio Grande train AI (A freight train AI)
RC11 since I was last here... Looks like I can't keep up with testing Nice job!
But it seems that some major bug remained. The AI often struggles with building new routes, there were games when it failed to build anything. There is one example in the ChooChoo thread, I have a posted savegame there and your AI dind't build anything in that game. I didn't wait for a very long time, it was trying two different routes and failing all the time.
And there is another problem, I see ANTSTART and ANTGOAL signs were there are no obstacles at all, where (I think) the crow should succeed without problems.
It is nice to see the improved ant pathfinder with the {C} signs, if only I could see the brand new kink remover in action...
Good luck in further development!
But it seems that some major bug remained. The AI often struggles with building new routes, there were games when it failed to build anything. There is one example in the ChooChoo thread, I have a posted savegame there and your AI dind't build anything in that game. I didn't wait for a very long time, it was trying two different routes and failing all the time.
And there is another problem, I see ANTSTART and ANTGOAL signs were there are no obstacles at all, where (I think) the crow should succeed without problems.
It is nice to see the improved ant pathfinder with the {C} signs, if only I could see the brand new kink remover in action...
Good luck in further development!
Re: Denver & Rio Grande train AI (A freight train AI)
I found another bug, the trains were started where there was no connection. I attached the screenshot and the savegame. Here the red player finds it hard to build new lines.
- Attachments
-
- R11 bug.png (67.23 KiB) Viewed 3854 times
-
- Unnamed, 30th Jun 1951.sav
- (100.16 KiB) Downloaded 149 times
-
- Engineer
- Posts: 58
- Joined: 19 Apr 2009 11:50
Re: Denver & Rio Grande train AI (A freight train AI)
Thanks for the comments.Brumi wrote:RC11 since I was last here... Looks like I can't keep up with testing Nice job!
But it seems that some major bug remained. The AI often struggles with building new routes, there were games when it failed to build anything. There is one example in the ChooChoo thread, I have a posted savegame there and your AI dind't build anything in that game. I didn't wait for a very long time, it was trying two different routes and failing all the time.
And there is another problem, I see ANTSTART and ANTGOAL signs were there are no obstacles at all, where (I think) the crow should succeed without problems.
It is nice to see the improved ant pathfinder with the {C} signs, if only I could see the brand new kink remover in action...
Good luck in further development!
There is an "invisible" fence around all the cities that will cause crow to invoke the ant. It in past it was blundering into dead ends the ant could not get out of. Imagine coming diagonally into a city with roads that almost meet and just passing through the "gate". If you see the crow put down {-} signs away from obstacles and more than 10 or so tiles from a city center I would love to seen a screenshot of the signs or a savegame.
EDIT: The dekinker now prints a {K} on the whole kink so you can see what's being considered for removal.
Can you post the save here or link the thread so I can take a look? The AI isn't super smart and some games are just hard for it to get going. Usually if one bankrupts the next one does better.
Last edited by Dustin on 28 Jul 2009 06:39, edited 1 time in total.
Re: Denver & Rio Grande train AI (A freight train AI)
Interesting. That's a good report. I don't have a clue what happened there. It shouldn't make trains if the track to a consumer didn't succeed. Sometimes a city will put down a road or change a slope just in time to spoil a route. It could be something related to that.Brumi wrote:I found another bug, the trains were started where there was no connection. I attached the screenshot and the savegame. Here the red player finds it hard to build new lines.
In any case, this station should be removed in about 2 years automatically. I will keep an eye out for that sort of thing. A savegame where it happens in the first 5-10 years would be super helpful.
Edit: I checked out the save, but I still don't know why this happened. Thanks for the report!
Last edited by Dustin on 28 Jul 2009 06:21, edited 1 time in total.
Re: Denver & Rio Grande train AI (A freight train AI)
Thanks for the report. 2cc hasn't been tested by me. So I am not surprised. Do you have a save game? It's trying to find a wagon to haul wood that will run on that track. I assume there is no monorail car for wood (it will refit wagons if it must). I never tested for what happens when there is no wagon to haul a good. So that's what caused the error.Dezmond_snz wrote:There is wrong something... (2cc TS)
I will think about how to fix this. The AI should still run, just not as well as it could.
- planetmaker
- OpenTTD Developer
- Posts: 9432
- Joined: 07 Nov 2007 22:44
- Location: Sol d
Re: Denver & Rio Grande train AI (A freight train AI)
When playing with the 2cc Train Set, it usually is sensible to not use monorail, but stick to electrified rail in the general case. Monorail is used by that set as a dedicated commuter train track, thus only PAX transport is available - with the advantage of fast loading / unloading and high-capacity PAX wagons.
OpenTTD: manual | online content | translations | Wanted contributions and patches
#openttdcoop: blog | wiki | public server | DevZone | NewGRF web translator
DevZone - home of the free NewGRFs: OpenSFX | OpenMSX | OpenGFX | Swedish Rails | OpenGFX+ Trains|RV|Industries|Airports|Landscape | NML
Re: Denver & Rio Grande train AI (A freight train AI)
planetmaker wrote:When playing with the 2cc Train Set, it usually is sensible to not use monorail, but stick to electrified rail in the general case. Monorail is used by that set as a dedicated commuter train track, thus only PAX transport is available - with the advantage of fast loading / unloading and high-capacity PAX wagons.
My AI isn't smart enough to figure out what rail is what. It just picks a valid one and goes! In NARS it picks electric rail and that's good because it can use a variety of engines. Thanks for the explanation. I will think about how to add a "best rail picker". Probably just count the number of wagons that are valid for a rail and pick the one with the highest count.
Typically unless you start with a late date, or the original bankrupts, you won;t get maglev or monorail.
- planetmaker
- OpenTTD Developer
- Posts: 9432
- Joined: 07 Nov 2007 22:44
- Location: Sol d
Re: Denver & Rio Grande train AI (A freight train AI)
Sure. NARS only provides (e)rail engines, thus monorail and maglev are de-activated automatically due to unavailability of vehicles.Dustin wrote:(...)In NARS it picks electric rail(...)
OpenTTD: manual | online content | translations | Wanted contributions and patches
#openttdcoop: blog | wiki | public server | DevZone | NewGRF web translator
DevZone - home of the free NewGRFs: OpenSFX | OpenMSX | OpenGFX | Swedish Rails | OpenGFX+ Trains|RV|Industries|Airports|Landscape | NML
Re: Denver & Rio Grande train AI (A freight train AI)
RC12 posted in main post.
Well at least in NARS monorail isnt avialable for a while, but electric is always there. So when I use this code I get the current "best". When does 2cc introduce monorail?
As a side note, I looked it up and there were electric "interurban" trains all over the U.S.A. in 1900! Around Seattle where I live now and in Colorado where I grew up. Victor and Cripple Creek had electric trains like a stray dog has fleas!
planetmaker wrote:Sure. NARS only provides (e)rail engines, thus monorail and maglev are de-activated automatically due to unavailability of vehicles.Dustin wrote:(...)In NARS it picks electric rail(...)
Well at least in NARS monorail isnt avialable for a while, but electric is always there. So when I use this code I get the current "best". When does 2cc introduce monorail?
Code: Select all
local types = AIRailTypeList();
AIRail.SetCurrentRailType(types.Begin());
- planetmaker
- OpenTTD Developer
- Posts: 9432
- Joined: 07 Nov 2007 22:44
- Location: Sol d
Re: Denver & Rio Grande train AI (A freight train AI)
Depends. If you set no NewGRF parameters monorail (or how it's called there metro tracks) are available from 1894 on. See http://users.tt-forums.net/2cc/readme.htmlDustin wrote: Well at least in NARS monorail isnt avialable for a while, but electric is always there. So when I use this code I get the current "best". When does 2cc introduce monorail?
OpenTTD: manual | online content | translations | Wanted contributions and patches
#openttdcoop: blog | wiki | public server | DevZone | NewGRF web translator
DevZone - home of the free NewGRFs: OpenSFX | OpenMSX | OpenGFX | Swedish Rails | OpenGFX+ Trains|RV|Industries|Airports|Landscape | NML
Re: Denver & Rio Grande train AI (A freight train AI)
thanksDustin wrote:Added the "{K}" sign (just for Brumi) to show rails that are kinked.
So I tested RC12, and it's nice to see that your AI is back on track again! It was building nicely, no more struggling with pathfinding.
The blank station bug occured again, but now it may be a clue that it was on a separate island. And when I spotted it, the last line in the AI Debug window was 'Build Route Waiting for more money...' You can see this in the attached savegame. There was a minor bug too, it should be quite easy to fix: And here is what I was speaking about, the ant pathfinder starts where there is no obstacle or even a town nearby. (Or does it apply to industries?) It caused no problems, just a little slowdown in pathfinding.
If I'm not too late, it's here in this post.Dustin wrote:Can you post the save here or link the thread so I can take a look? The AI isn't super smart and some games are just hard for it to get going. Usually if one bankrupts the next one does better.
There is a setting called 'Minimum transport cargo percent per industry'. Does it mean that your AI won't compete if a higher percentage is transported from the industry? (like in TransAI)
I don't want to seem like that I keep posting bugs all the time, your AI is really improving. I think it will become a really good one over time.
Re: Denver & Rio Grande train AI (A freight train AI)
Didn't Dustin state somewhere above that he always uses ant at the last few tiles of a connection?Brumi wrote:[...]
And here is what I was speaking about, the ant pathfinder starts where there is no obstacle or even a town nearby. (Or does it apply to industries?) It caused no problems, just a little slowdown in pathfinding.
[image]
----
I haven't gotten around to testing your AI before, but now I've done it (as promised in another thread .
I really like the fresh ideas you've brought into your AI here. Also very nice is how you can really watch the AI while he's thinking, unlike other AIs that just plot and plot and plot silently and then *bang* spit out a route
Anyway, here's a few things I noticed:
Image 1: I don't really know why bridge was invoked here in the first place. It should be perfectly fine to lay a straight track down there. Maybe the coast tiles are irritating crow. Image 2: Building a passing lane failed here. Image 3: The passing lane builder inadvertently connected the line to a station of another line. edit:typo
Re: Denver & Rio Grande train AI (A freight train AI)
Here's another thing I noticed, it's more of a design problem than a bug actually.
D&RG AI often fails building something due to its own track being in the way. Here's what I think the problem is: Often, situations like in the image above happen (if he already built some lines, or other players/AI did).
Unlike cities or industries, existing track is a kind of obstacle that is best bridged over / tunneled under, not gone around (should be obvious).
However, as far as I understand how your AI works, there's only one chance to manage that. As soon as crow has defined the start and the ending point of the path that it's not able to manage itself, it passes these two points to bridge first, then to ant.
More often than not, bridge is NOT able to handle this, because either crow was going in a diagonal, or there's a height difference between start and ending point, or something else is inbetween (a town, ...).
Of course ant also fails because it's in most cases impossible to go around an existing route.
---
You already wrote that you wanted to introduce some other sub-pathfinders (before resorting to ant at the very last), so maybe these could be able to tackle cases like in the above screenshot?
------------
EDIT: found another bug (I guess):
your AI created a big aisle through the map. Maybe it tried to level something at the border of the map and made some "modulo map border" error?
Last thing said, please don't take this critique too harsh, I really like your AI. I just want to help you improve it further (lol, that reminds me of "thank you for helping us help you help us all")
D&RG AI often fails building something due to its own track being in the way. Here's what I think the problem is: Often, situations like in the image above happen (if he already built some lines, or other players/AI did).
Unlike cities or industries, existing track is a kind of obstacle that is best bridged over / tunneled under, not gone around (should be obvious).
However, as far as I understand how your AI works, there's only one chance to manage that. As soon as crow has defined the start and the ending point of the path that it's not able to manage itself, it passes these two points to bridge first, then to ant.
More often than not, bridge is NOT able to handle this, because either crow was going in a diagonal, or there's a height difference between start and ending point, or something else is inbetween (a town, ...).
Of course ant also fails because it's in most cases impossible to go around an existing route.
---
You already wrote that you wanted to introduce some other sub-pathfinders (before resorting to ant at the very last), so maybe these could be able to tackle cases like in the above screenshot?
------------
EDIT: found another bug (I guess):
your AI created a big aisle through the map. Maybe it tried to level something at the border of the map and made some "modulo map border" error?
Last thing said, please don't take this critique too harsh, I really like your AI. I just want to help you improve it further (lol, that reminds me of "thank you for helping us help you help us all")
Re: Denver & Rio Grande train AI (A freight train AI)
Excellent. Crow chokes when the station starts right next to water. If crow can't even get one tile off things go wrong.Brumi wrote:thanksDustin wrote:Added the "{K}" sign (just for Brumi) to show rails that are kinked.
So I tested RC12, and it's nice to see that your AI is back on track again! It was building nicely, no more struggling with pathfinding.
The blank station bug occured again, but now it may be a clue that it was on a separate island. And when I spotted it, the last line in the AI Debug window was 'Build Route Waiting for more money...' You can see this in the attached savegame.
Minor: yes.There was a minor bug too, it should be quite easy to fix:
Easy to fix: nope.
This is in the newest part of the code, which I rushed and worked on when I was seriously tired. In fact, the code is so bad it's riddled with infinite loop buster code. I may just start from scratch and do it over better.
The passing lanes work often enough that the AI can run a decent number of trains, so this failure is not ideal, but not a "ship stopper".
Ah. Yeah, that is the END. Not the start. Crow always hands over to ant at the very end. Yes, that's messy, but the links are much cleaner.
And here is what I was speaking about, the ant pathfinder starts where there is no obstacle or even a town nearby. (Or does it apply to industries?) It caused no problems, just a little slowdown in pathfinding.
Thanks, I will look at the save when I get a chance. EDIT: I looked. Yeah, D&RG is doomed on that map. It needs enough space to place it's initial stations in a flat place near a producer and consumer. It does finnally find that, but doesn't have the cash to complete the link. I typically test in bigger maps. D&RG isn't a small map AI.If I'm not too late, it's here in this post.Dustin wrote:Can you post the save here or link the thread so I can take a look? The AI isn't super smart and some games are just hard for it to get going. Usually if one bankrupts the next one does better.
There is a setting called 'Minimum transport cargo percent per industry'. Does it mean that your AI won't compete if a higher percentage is transported from the industry? (like in TransAI)
A new train will be built if the % transported is below this number for about 1 year. (Or actually if it's lower exactly when I check once a year.) So a coal mine at 51% would never get a new train if the setting was 50. but it would get another added if it hits 49%. Provided the AI thinks there is room for more. The producer stations name say something like (2/3) meaning that 2 out of a possible three trains are believed to be running.
EDIT: My AI won't compete if you even have a station in range of the industry. It tries to do it's own thing and not get mixed up with others. I might change that to look for underserved producers so that PAX stations won't scare it off.
My day job is Software Tester. I completely respect what you are doing here. Keep the feedback coming. It's very gratifying.I don't want to seem like that I keep posting bugs all the time, your AI is really improving. I think it will become a really good one over time.
Last edited by Dustin on 29 Jul 2009 06:49, edited 1 time in total.
Re: Denver & Rio Grande train AI (A freight train AI)
Thanks so much for the kind words. This AI actually started when I read about Pathzilla and Ant Colony computing on the same day. So the AI is really just a wrapper for my custom AI.Roujin wrote: ----
I haven't gotten around to testing your AI before, but now I've done it (as promised in another thread .
I really like the fresh ideas you've brought into your AI here. Also very nice is how you can really watch the AI while he's thinking, unlike other AIs that just plot and plot and plot silently and then *bang* spit out a route
Yep, crow thinks of coast the same as water. On day Seagull will step in and understand coasts better.Anyway, here's a few things I noticed:
Image 1: I don't really know why bridge was invoked here in the first place. It should be perfectly fine to lay a straight track down there. Maybe the coast tiles are irritating crow.
Yeah, that routine is just terrible. I had it working pretty nice, but then it had some infinite loops at times. I added code to fix them and the passing lanes started showing problems. Sometimes around bridges the get messed up too.Image 2: Building a passing lane failed here.
That's interesting, but I don't consider it a problem. The trains don't seem to mind. If you see a link where this causes trains to get lost I would love to hear about it.Image 3: The passing lane builder inadvertently connected the line to a station of another line. edit:typo
Thanks again for the tournament and the report.
Re: Denver & Rio Grande train AI (A freight train AI)
You understand exactly. Bridge is REALLY dumb and if crow was Diagonal, it's doomed. So yes, I plan on improving bridge and I have been toying with creating Mole. (You can guess what that might do.)Roujin wrote:Here's another thing I noticed, it's more of a design problem than a bug actually. [snip...]---
You already wrote that you wanted to introduce some other sub-pathfinders (before resorting to ant at the very last), so maybe these could be able to tackle cases like in the above screenshot?
Wow, nice. Looks like a legit OTTD bug. The AI is calling "AITile.LevelTiles(tile, tile + AITile.GetIndex(-10, -10))" for example. Looks like it wrapped indeed. The AI doesn't check the validity of the tiles. Just tries to flatten areas around producers to fit stations in.------------
EDIT: found another bug (I guess):
your AI created a big aisle through the map. Maybe it tried to level something at the border of the map and made some "modulo map border" error?
Not at all. I am thrilled to be getting so much thoughtful feedback. Thank you very much.Last thing said, please don't take this critique too harsh, I really like your AI. I just want to help you improve it further (lol, that reminds me of "thank you for helping us help you help us all")
Re: Denver & Rio Grande train AI (A freight train AI)
How is OpenTTD supposed to know that leveling 'tile on one side of map' to 'tile on other side of map' means leveling till the map's border? And if so, till which map border?Dustin wrote:Wow, nice. Looks like a legit OTTD bug. The AI is calling "AITile.LevelTiles(tile, tile + AITile.GetIndex(-10, -10))" for example. Looks like it wrapped indeed. The AI doesn't check the validity of the tiles. Just tries to flatten areas around producers to fit stations in.
Who is online
Users browsing this forum: No registered users and 16 guests