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

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 »

Eliandor wrote:Mm, too much screenshots (did I appologize for checking so much already?)

When it removed the unprofitable route (the one it actually managed to remove, where the trains could be send to the depot), it also removed an essential part of the other route. I guess it would've removed the top left crossing as well, if there wasn't any train there.
DandRG_station_flaw_oneCons.png
EDT: build a Iron Ore - Steel line but Consumer wasn't close enough to Steel Mill.
DandRG__Wund_no_coverage_flaw.png
EDT 2: finally! The holes I was talking about.
DandRG_hole.png
EDT 3: can't really screenshot this. When having nothing to do, D&RG takes a full loan / repays all / takes a full loan / repays all. It doesn't really get in the way of building, but it looks... weird. It also says "Waiting for money" while it can easily take more loan. (540k out of 1m)

All good reports. Can you send me the screenshot of the station and the steel mill in the same shot so I can see where it put it? That code is brand new and I am not surprised it's got a problem.

The "holes" are by bridge. It's trying to make the tiles on each end of a possible bridge the same level. I'll think about a fix. Clearly that hole won't help at all.
Actually DR&G is taking the max loan and paying it back really fast. So it seems like it doesn't get the full amount, but I logged it and it does. It's sort of sloppy, but it works (like a lot of the AI!).

-D
User avatar
1009
Engineer
Engineer
Posts: 81
Joined: 22 Mar 2009 07:24
Location: Haarlem, The Netherlands
Contact:

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

Post by 1009 »

Dustin wrote:All good reports. Can you send me the screenshot of the station and the steel mill in the same shot so I can see where it put it? That code is brand new and I am not surprised it's got a problem.

The "holes" are by bridge. It's trying to make the tiles on each end of a possible bridge the same level. I'll think about a fix. Clearly that hole won't help at all.
Actually DR&G is taking the max loan and paying it back really fast. So it seems like it doesn't get the full amount, but I logged it and it does. It's sort of sloppy, but it works (like a lot of the AI!).

-D
I'm trying to recreate the Steel Mill situation. I don't save my games most of the times, I just let it run for a few hours, watching the log / progress every now and then.
EDT: I can describe it though. The steel mill was on a huge hill, and it put it just a few tiles too much northwest of it. Not on the hill, but on the "floor".

About the loan: can't you check, when in need of money, whether there is more loan available? Oh well, I guess it doesn't really matter XD it just looks funny =P
User avatar
1009
Engineer
Engineer
Posts: 81
Joined: 22 Mar 2009 07:24
Location: Haarlem, The Netherlands
Contact:

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

Post by 1009 »

Bugs:

= it built tracks instead of the Consumer station. At the start of pathfinding it said that the consumer station already existed, so I guess that's the problem. It re-built the route now, still no consumer station.
EDT: in a new game (the one with the failed coal mine in the beginning, see below) it removed the consumer station (because the route failed), but after a short time, I get "consumer station already exists" -- there are absoluty no stations. See attachment, happens 18th Jan. It seems to happen every time it searches for a consumer station. {006}
Consumer station not built
Consumer station not built
DandRG_consumer_station_flaw.png (116.6 KiB) Viewed 1638 times
Unnamed, 11th Feb 1960.sav
Bug-save.
(97.29 KiB) Downloaded 193 times
= it built two producer stations for the same industry. One of them is connected to a consumer station that has the same flaw as http://www.tt-forums.net/viewtopic.php?p=811965#p811965 as reported previously, that might be the cause of it building another service (since you introduced a "make a new line of other service is bad")

= while trying to connect a coal mine to a power plant it encountered a wrongly sloped land piece. Bridge lowered this, and ant assumed it was still able to get around (I think). It's trying to build on the next tile. I have a save file too, if you want to reproduce. It's the first thing it does.
Land sloped wrong
Land sloped wrong
DandRG_LandSlopedWrong.png (82.51 KiB) Viewed 5504 times
Last edited by 1009 on 23 Aug 2009 21:45, edited 1 time in total.
User avatar
1009
Engineer
Engineer
Posts: 81
Joined: 22 Mar 2009 07:24
Location: Haarlem, The Netherlands
Contact:

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

Post by 1009 »

= {007} weird bridge construction (from now on I'll be numbering the reports, so I can refer to them more easily.)
Weird bridge construction
Weird bridge construction
DandRG_bridge_flaw.png (74.27 KiB) Viewed 1658 times
Last edited by 1009 on 23 Aug 2009 21:46, 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 »

Eliandor wrote:= {000} weird bridge construction (from now on I'll be numbering the reports, so I can refer to them more easily.)
DandRG_bridge_flaw.png
Arg, that's a really longstanding bug I haven't been able to get.

The error where a deleted station is said to already exist. Yeah, it never removes them from the master list! Good catch.
I don't have time for a detailed comment on all the bugs, but good work. Keep them coming. I appreciate it. I will add your name to the list of testers at startup.
If you go back and edit in bug numbers, that will help too.

Thanks again.
User avatar
1009
Engineer
Engineer
Posts: 81
Joined: 22 Mar 2009 07:24
Location: Haarlem, The Netherlands
Contact:

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

Post by 1009 »

Dustin wrote: The error where a deleted station is said to already exist. Yeah, it never removes them from the master list! Good catch.
I don't have time for a detailed comment on all the bugs, but good work. Keep them coming. I appreciate it. I will add your name to the list of testers at startup.
If you go back and edit in bug numbers, that will help too.

Thanks again.
Alright, I'll re-number those, I'm glad to help.
I'll bug test the next version again, I might accidentally fill double reports otherwise.
Dustin wrote:
Eliandor wrote:Arg, that's a really longstanding bug I haven't been able to get.
It's most likely in the continuing after the bridge pathfinder.
When it searches for the next tile to build, doesn't every tile adjacent to the bridge end qualify as a possible new starting spot for crow / ant / new bridge?
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 »

Dustin wrote:
Eliandor wrote:Arg, that's a really longstanding bug I haven't been able to get.
It's most likely in the continuing after the bridge pathfinder.
When it searches for the next tile to build, doesn't every tile adjacent to the bridge end qualify as a possible new starting spot for crow / ant / new bridge?
Bridge actaully includes the two tiles that aren't part of the bridge, but are before and after it to keep from causing this very problem. I think that these little bridges are due to convuluted ant paths (or a bug in them) and the inability for the unkinker to fix them. When the unkinker is killed, I often see the track failing and getting removed and it maybe that it was killed right before this error occurred.

If I had it to do over, I would have a data structure for track that explicity says where the bridges are. The bridges are implicit anytime there is a gap. Which is the pattern the examples on the wiki use. I shouldn't have followed that example, I think.
Brumi
President
President
Posts: 921
Joined: 18 Jul 2009 17:54

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

Post by Brumi »

Consider this anything you want, it's not neccessarily a bug report, but I couldn't pass this without posting it here:
funny ant path.png
funny ant path.png (239.79 KiB) Viewed 1643 times
That could have been the wildest ant path I've ever seen. The problem was that the pathfinder failed elsewhere, so I didn't see what the AI would make out of this.
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:Consider this anything you want, it's not neccessarily a bug report, but I couldn't pass this without posting it here:
funny ant path.png
That could have been the wildest ant path I've ever seen. The problem was that the pathfinder failed elsewhere, so I didn't see what the AI would make out of this.
Yeah, the ant does that quite a bit if you watch. The ant wanders around sort of at random, but mostly in the direction of the goal. It isn't allowed to cross it's own path, so concave obstacles will cause it to double back until it fills in the hole, or traps itself (like a tron light cycle, boom!).

The unkinker, in theory, would short circuit the path to make it fairly effecient. That messy a path would most likely have choked the unkinker anyway, it's pretty buggy still.
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 »

Realease D2 added to main post. Just a few bug fixes.
  • No more holes. Might still build some mounds though.
  • Better cleanup should keep producer stations from getting disconnected.
  • Fix for "ghost" stations where only the rails show up.
  • Fixed some crashing bugs.
User avatar
1009
Engineer
Engineer
Posts: 81
Joined: 22 Mar 2009 07:24
Location: Haarlem, The Netherlands
Contact:

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

Post by 1009 »

It's good to see this new release! I started testing right away (you may notice a difference in screenshot; I switched to OpenGFX for this game)
If there's any other way I can help you should say so. I'm not too great at Squirrel, alas, but I'm getting lessons in C at school this year.

Suggestions:
= include the default pathfinder too, so it goes Crow - Bridge - Ant - Default. Ant now and then doesn't find a solution to a seemingly quite easy problem.
= when there's not enough money, let the AI pathfind anyway. Since that takes the most time, it can store found routes in it's memory. I guess this is a tricky one though.
= when connecting a grain/livestock station in temperate, let it build trains grain - livestock - grain - livestock. If that's not too hard, of course, it's only a small advantage anyway if it'd do it like that.
= check for a minimum length of a passing lane. It happens quite oftenly that it builds too short passing lanes and the route becomes a net loss. Even without any passing lane you'd get more profit.

{008} pathfinder thought it'd be possible to place a tunnel on water.
D&RG - Cannot build tunnel on water
D&RG - Cannot build tunnel on water
DandRG_tunnel_on_water.png (22.91 KiB) Viewed 5122 times
{009} after bridge pf it passed a wrong tile to the next pf, track not connected.
Bridge PF and afterwards.
Bridge PF and afterwards.
DandRG_bridge_passing.png (54.79 KiB) Viewed 1623 times
{010} ants best path needs a little improvement (not a real bug, but hey.)
Ant determined a weird best path.
Ant determined a weird best path.
DandRG_ant_best_path.png (19.85 KiB) Viewed 5112 times
Last edited by 1009 on 29 Aug 2009 18:47, edited 2 times in total.
User avatar
1009
Engineer
Engineer
Posts: 81
Joined: 22 Mar 2009 07:24
Location: Haarlem, The Netherlands
Contact:

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

Post by 1009 »

{010} / {007}, weird ant & bridge combined.
DandRG_bridge_ant.png
DandRG_bridge_ant.png (17.93 KiB) Viewed 5110 times
{011} it reports "station already exists at this consumer" even if that's not the case. Building of the stations still is fine anyway.

Aaand something good: building a little hill helped bridge get over! Looks beautiful.
DandRG_bridge_helper.png
DandRG_bridge_helper.png (43.73 KiB) Viewed 5108 times
{012} that's quite a big hill. Maybe limit bridge to only 1 tile hills?
DandRG_bridge_hill.png
DandRG_bridge_hill.png (93.02 KiB) Viewed 5103 times
User avatar
1009
Engineer
Engineer
Posts: 81
Joined: 22 Mar 2009 07:24
Location: Haarlem, The Netherlands
Contact:

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

Post by 1009 »

{013} when rail cleanup should be happening because path failed, but is intercepted by an event, it leaves the track to rot.
DandRG_no_cleanup.png
DandRG_no_cleanup.png (20.77 KiB) Viewed 5088 times
I can confirm that it doesn't clean up the whole Producer station now once one of its Consumers makes a net loss. I also tested it with a failed path, worked flawlessly. Congrats.
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 »

Bug list post

Current list of known issues.
{000} weird bridge construction
- Known issue, no fix yet

FIXED D3 {008} pathfinder tries to place tunnels on water.
- Actualy the AI never builds tunnels. I think this error message is wrong. Clearly the AI is having problems with paths near shorelines though.

{009} after bridge pf it passed a wrong tile to the next pf, track not connected.
- Right angle bridges have been a problem in the past. Thought I fixed it. Will look into it.

{010} ants best path needs a little improvement (not a real bug, but hey.)
- this is a failure of the un-kinker. It should have "cut off" the outside loop. So its a real bug. This one is hard to work on. Might need to custom make a scenario that forces the AI to display this bug on the first route.

FIXED D3 {011} it reports "station already exists at this consumer" even if that's not the case. Building of the stations still is fine anyway.
- Still not cleaning up stations from the master list.
- It might say a station exists that hasn't been built, but the space is reserved already so it exists to the AI.

FIXED D3 {012} that's quite a big hill. Maybe limit bridge to only 1 tile hills?
- Yeah, that is a big hill. A limit should easy to make.

FIXED D4 {013} when rail cleanup should be happening because path failed, but is intercepted by an event, it leaves the track to rot.
- This used to work before. Not sure what caused this bug. Needs looking into.

{014} include default pathfinder to backup bridge.
- Won't fix. Custom pathfinders forever! I admit it still needs work.

{015} Let AI pathfind when there isn't enough money
- Good idea. Probably work on it later. However, the map changes over time, so the routes would have a higher failure rate.

{016} when connecting a grain/livestock station in temperate, let it build trains grain - livestock - grain - livestock
- The AI will build one of each, then add more as needed. So a farm with lots of grain will get more grain trains than livestock. I think this is actually working really well.

FIXED D3 (new length is trainsize * 2) {017} check for a minimum length of a passing lane
- There already is a check, can you show my an example of one that's too short? I just need to tune the length.

{018} Shared stations can get really crowded. They should be roro or expanded.
- Stations used to be roro, but I changed them to save space. I need to redo my depot placement in order to easily go back to roro.

FIXED D4 {019} AI raises the topmost tile on the map during pathfinding, leaving a hill there.
- Wastes money, but isn't a big deal.

{020} ant encounters hill built by bridge but still think it's flat? I wasn't able to catch the built tracks before they were removed, but this was the spot.
- Good bug. Tough to fix without removing bridges ability to even the bridgeheads.

FIXED D3 {021}, it didn't remove the consumer station
- This is a bug, the reference count for the consumer doesn't get decremented when the tracks fail.
Last edited by Dustin on 30 Aug 2009 20:00, edited 3 times in total.
User avatar
1009
Engineer
Engineer
Posts: 81
Joined: 22 Mar 2009 07:24
Location: Haarlem, The Netherlands
Contact:

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

Post by 1009 »

I know how I can help: shall I develop a web-api for D&RG bug reporting? I can even host it xD just give me a heads up if you're interested :).

Clarifying {016}: it built two grain trains right away, then added a livestock train. Though, since there's only two tracks, no livestock's loaded (both grain trains were first) -- livestock starts when the first grain train leaves. But this is just really really really small XD

About {017}: I'll show you one in the next game I'll be starting, it does so quite oftenly. The length is fine (or seems to be fine), but since the signals are placed in the middle of the track only half of it is used.

Addendum: even though at this particular location it hasn't encountered another train yet, this is more or less what I mean. When another train comes from the opposite side they'll be stuck.
DandRG_passing_lane_too_short.png
DandRG_passing_lane_too_short.png (41 KiB) Viewed 5048 times
Last edited by 1009 on 29 Aug 2009 20:05, edited 1 time in total.
Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

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

Post by Yexo »

Eliandor wrote:I know how I can help: shall I develop a web-api for D&RG bug reporting? I can even host it xD just give me a heads up if you're interested :).
While it's nice of you to offer that, OpenTTD already offers that service at http://noai.openttd.org/
User avatar
1009
Engineer
Engineer
Posts: 81
Joined: 22 Mar 2009 07:24
Location: Haarlem, The Netherlands
Contact:

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

Post by 1009 »

Yexo wrote:While it's nice of you to offer that, OpenTTD already offers that service at http://noai.openttd.org/
Alright, I'll just be bug checking then :)

{020} ant encounters hill built by bridge but still think it's flat? I wasn't able to catch the built tracks before they were removed, but this was the spot.
DandRG_hill_ant.png
DandRG_hill_ant.png (28.57 KiB) Viewed 5051 times
Also, {021}, it didn't remove the consumer station (but that might be because it thinks it's still in the industry list, {011}?)
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 »

Yexo wrote:
Eliandor wrote:I know how I can help: shall I develop a web-api for D&RG bug reporting? I can even host it xD just give me a heads up if you're interested :).
While it's nice of you to offer that, OpenTTD already offers that service at http://noai.openttd.org/
Yes but not for me because I can't use the required license. Anyway I have my own webhost. So if I get motivated enough I will set up bugzilla.
User avatar
1009
Engineer
Engineer
Posts: 81
Joined: 22 Mar 2009 07:24
Location: Haarlem, The Netherlands
Contact:

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

Post by 1009 »

Dustin wrote:
Yexo wrote:
Eliandor wrote:I know how I can help: shall I develop a web-api for D&RG bug reporting? I can even host it xD just give me a heads up if you're interested :).
While it's nice of you to offer that, OpenTTD already offers that service at http://noai.openttd.org/
Yes but not for me because I can't use the required license.
In that case my offer still stands.

{022} still removes a slight tad too much track at the consumer if one of its producers makes a new loss.
DandRG_consumer_removal.png
DandRG_consumer_removal.png (40.04 KiB) Viewed 5045 times
About {019}: no idea when exactly it does so, but the last message I got in the debug window was "ant found a way around", last event was a net loss of some route. May have to do with that, but I have no idea. :/
User avatar
1009
Engineer
Engineer
Posts: 81
Joined: 22 Mar 2009 07:24
Location: Haarlem, The Netherlands
Contact:

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

Post by 1009 »

D3

{023} crash after trying to build on bridge-leveled ant-track.
DandRG_bridgehill_crash.png
DandRG_bridgehill_crash.png (53.83 KiB) Viewed 1620 times
DandRG_bugreport_023_crash.sav
(170.73 KiB) Downloaded 173 times
{024} doesn't remove "Start 2" and "Index 64" debug signs at producer industries.

{008} hasn't been solved yet
DandRG_tunnel_water_crash.png
DandRG_tunnel_water_crash.png (56.21 KiB) Viewed 1622 times
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 8 guests