Some AI problems with builder of rail networks
Moderator: OpenTTD Developers
Some AI problems with builder of rail networks
I have a few questions about the construction of the railway network.
An example from the last game. My AI built the railroad copper mine - the factory, which is served by 4 trains. (length ~ 200 tiles)
Copper mine Factory Station for the transport of rubber is attached to this rail. The line of rubber plantation - factory also served four trains. (length ~ 150 tiles) 1) I chose the way of loading cargo on a train at the same time. All the AI I've seen build the station with two ways. And often you can see the loading of cargo on two trains at same time. Which way is better?
2) Trains running in the direction of the copper mine sometimes call in service at the depot near the rubber plantation. Why?
The service interval is set at 250 days. Train forcibly enters the depot immediately after unloading.
I can program the construction of the reverse loop. But this solution does not seem to me successful.
Are there any ideas how to avoid?
3) AI next step is joining another industry to the factory. How I can estimate the limiting density of traffic on this route, that average speed fell slightly relative to the max speed of engine.
4) Is there in part of any other AIs block of optimizer rail network? In some place intersect 3 independent railways built at different times. In some instances need to rebuild the initial rail tracks, when building a third rail routes, for the optimal crossing.
An example from the last game. My AI built the railroad copper mine - the factory, which is served by 4 trains. (length ~ 200 tiles)
Copper mine Factory Station for the transport of rubber is attached to this rail. The line of rubber plantation - factory also served four trains. (length ~ 150 tiles) 1) I chose the way of loading cargo on a train at the same time. All the AI I've seen build the station with two ways. And often you can see the loading of cargo on two trains at same time. Which way is better?
2) Trains running in the direction of the copper mine sometimes call in service at the depot near the rubber plantation. Why?
The service interval is set at 250 days. Train forcibly enters the depot immediately after unloading.
I can program the construction of the reverse loop. But this solution does not seem to me successful.
Are there any ideas how to avoid?
3) AI next step is joining another industry to the factory. How I can estimate the limiting density of traffic on this route, that average speed fell slightly relative to the max speed of engine.
4) Is there in part of any other AIs block of optimizer rail network? In some place intersect 3 independent railways built at different times. In some instances need to rebuild the initial rail tracks, when building a third rail routes, for the optimal crossing.
Re: Some AI problems with builder of rail networks
@1
If you have two trains in one station, and they load sequentially, not simultaneously, then your station rating will be a bit higher as there will always be a train waiting: when one is leaving, the next one starts loading and the third train can entre the station.
@2
Maybe you have a savegame so I can check this. But if you'd enter explicit "go to depot" orders, trains should skip other depots than those in the order list.
@3
This I do not know: I have almost no knowledge of the NoAI api and I 2+ track routes with load balancing is hard enough in single player games for a user.
@4
You could take a look at ChooChoo, this AI tries to build a network.
If you have two trains in one station, and they load sequentially, not simultaneously, then your station rating will be a bit higher as there will always be a train waiting: when one is leaving, the next one starts loading and the third train can entre the station.
@2
Maybe you have a savegame so I can check this. But if you'd enter explicit "go to depot" orders, trains should skip other depots than those in the order list.
@3
This I do not know: I have almost no knowledge of the NoAI api and I 2+ track routes with load balancing is hard enough in single player games for a user.
@4
You could take a look at ChooChoo, this AI tries to build a network.
Re: Some AI problems with builder of rail networks
3a) Calculating density
Lets start with a single connection. (the simpliest case)
You have X trains over a distance of Y.
K = X/Y gives the density of trains (number of trains per length unit) over the section. If you have different train lengths on different connections, you better calculate K as X/Y * [train length] to get a neutral figure.
You could say that when the density goes over a limit Kmax, then no more trains is allowed on the section. If you then also allow multiple connections to reuse the same track, then you will get sections between each junction for which you have to calculate the density.
I suggest that you see the junctions as nodes, and do not try to figure out the density of the individual track parts of a junction. Later you could try to do that if you want, but leave it out now, as that would add even more complexity.
3b. Denisity limit
I think your best bet is to experiment and find a Kmax value that works good for you. If you know the relation between speed, flow and density , then you could analytically solve which Kmax value that maximize the flow. However, as far as I know, nobody has done any attempts to build any functions to describe the traffic dynamics in OpenTTD. You should also notice that as you get higher and higher density, the system will have a higher chance of flow break downs. So even if you could analytically maximize the flow, you would still not want to use the found Kmax value as that would give a rather unstable system.
Edit: And in the case of railways, you will have to take the signal distance into account as well. If it is constant over all your rail tracks, then you can probably ignore it as a parameter for Kmax. Though it will affect the experimentally found Kmax value.
Lets start with a single connection. (the simpliest case)
You have X trains over a distance of Y.
K = X/Y gives the density of trains (number of trains per length unit) over the section. If you have different train lengths on different connections, you better calculate K as X/Y * [train length] to get a neutral figure.
You could say that when the density goes over a limit Kmax, then no more trains is allowed on the section. If you then also allow multiple connections to reuse the same track, then you will get sections between each junction for which you have to calculate the density.
I suggest that you see the junctions as nodes, and do not try to figure out the density of the individual track parts of a junction. Later you could try to do that if you want, but leave it out now, as that would add even more complexity.
3b. Denisity limit
I think your best bet is to experiment and find a Kmax value that works good for you. If you know the relation between speed, flow and density , then you could analytically solve which Kmax value that maximize the flow. However, as far as I know, nobody has done any attempts to build any functions to describe the traffic dynamics in OpenTTD. You should also notice that as you get higher and higher density, the system will have a higher chance of flow break downs. So even if you could analytically maximize the flow, you would still not want to use the found Kmax value as that would give a rather unstable system.
Edit: And in the case of railways, you will have to take the signal distance into account as well. If it is constant over all your rail tracks, then you can probably ignore it as a parameter for Kmax. Though it will affect the experimentally found Kmax value.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Junctioneer (a traffic intersection simulator)
Re: Some AI problems with builder of rail networks
How can I make that two trains at one station will be loaded sequentially? Usually they are loaded simultaneously.Arie- wrote:@1
If you have two trains in one station, and they load sequentially, not simultaneously, then your station rating will be a bit higher as there will always be a train waiting: when one is leaving, the next one starts loading and the third train can entre the station.
I havent savegame.Arie- wrote: @2
Maybe you have a savegame so I can check this.


What interval of service need to set in this case?Arie- wrote: But if you'd enter explicit "go to depot" orders, trains should skip other depots than those in the order list.
Thx.Arie- wrote:@4
You could take a look at ChooChoo, this AI tries to build a network.
Re: Some AI problems with builder of rail networks
Excellent introduction for the beginning!Zuu wrote:...


Kmax value... I need array of all common blocks of network of rail routes. I need list of trains passing through these blocks.
Is it enough functions in the API to build a virtual map of transport routes of the current railway network? Or I need an array that is filled immediately after the construction of the rail routes?
Re: Some AI problems with builder of rail networks
It should be possible using just the API and "walking" the tracks found on the map, but it's usually easier to do this as you're building the routes, when you still have higher level "A connects to B through junction C" information available.ilt wrote:Is it enough functions in the API to build a virtual map of transport routes of the current railway network? Or I need an array that is filled immediately after the construction of the rail routes?
By the way, ChooChoo does build networks, but only because it works by building and expanding its four way junctions. It doesn't reuse tracks, nor does it optimize already existing tracks.
Re: Some AI problems with builder of rail networks
While as Michel said, you have easier access to higher level information while you are building, you will have use for a map-walker. A map-walker can recover crashed AIs and could also be used in your load-code and thus remove the need of storing any extra information in the map. This has the bonus benefit that both the crash-recover code and the load-code is the same code and is thus regularly tested. If you later find that the map-walking code is too slow, and you can't find any way to speed it up for common cases, then you could look into saving extra information in the save games that could speed up the loading.ilt wrote:Is it enough functions in the API to build a virtual map of transport routes of the current railway network? Or I need an array that is filled immediately after the construction of the rail routes?
Having a strict standardized way of building junctions could simplify the map-walking process. You should put some though into building your rail with readability in mind.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Junctioneer (a traffic intersection simulator)
Re: Some AI problems with builder of rail networks
I used to planning and building a rail route RailPathFinder library. During last week i found that it works too slow if the distance becomes greater than 150 tiles.
Pathfinding works 1-2-3 years per route
I am trying to tweak it settings, but the difference in the speed of his work, i dont see.
Now this is the main problem of my AI. Three 50 tiles rail routes are built for 4-5 months. One 150 tiles rail route are built for 1-3 years.
Why?
Solutions:
1. Tweak existing pathfinder. How?
2. Make my own pathfinder.
3. Overwrite existing pathfinder.
4. Use existing pathfinder, but total distance divided into some short parts.
5. Any useable idea?
How do I solve this problem?
P.S. If i press fast forward button AI thinks slowly (more game days / months / years)? or as usual?
Pathfinding works 1-2-3 years per route

Now this is the main problem of my AI. Three 50 tiles rail routes are built for 4-5 months. One 150 tiles rail route are built for 1-3 years.
Why?

Solutions:
1. Tweak existing pathfinder. How?
2. Make my own pathfinder.
3. Overwrite existing pathfinder.
4. Use existing pathfinder, but total distance divided into some short parts.
5. Any useable idea?
How do I solve this problem?
P.S. If i press fast forward button AI thinks slowly (more game days / months / years)? or as usual?
Re: Some AI problems with builder of rail networks
I reused railway pathfinder from ChooChoo.
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD
AIAI - AI for OpenTTD
Re: Some AI problems with builder of rail networks
Could be done by :ilt wrote:1. Tweak existing pathfinder. How?
orilt wrote:2. Make my own pathfinder.
ilt wrote:3. Overwrite existing pathfinder.
You could just overwrite the RailPF._Estimate() to return higher value then it normally return.ilt wrote:4. Use existing pathfinder, but total distance divided into some short parts.
5. Any useable idea?
How do I solve this problem?
See : here
Re: Some AI problems with builder of rail networks
My experiments with RailPF moving forward. I have some results! 
I'm working on the building of a parallel path to the first found. I dont use RailPF here or use for difficult sections of track (short length).
RailPF returns an object Aystar. I dont understand the benefits of working with this object and converts it into an array.
Maybe I dont understand something and reinvent the wheel. Can anyone explain what are the advantages of this object?

I'm working on the building of a parallel path to the first found. I dont use RailPF here or use for difficult sections of track (short length).
RailPF returns an object Aystar. I dont understand the benefits of working with this object and converts it into an array.
Maybe I dont understand something and reinvent the wheel. Can anyone explain what are the advantages of this object?

Who is online
Users browsing this forum: No registered users and 9 guests