Page 1 of 2

Wait for Full Load - Until another train arrives

Posted: 25 Aug 2005 10:50
by boekabart
I have (and implemented and tested) an idea to modify the current Wait Until Full behaviour.
Often, I have a station where i want to have a train loading cargo at every time. In order to do this, I enable Full Loading (with the patch), and make sure that there are enough trains running to have always at least one waiting at the station.
Now i was wondering, isn't it better if the first train leaves the moment the next one arrives at the station, even if it's not full yet? This way, cargo is delivered as quick as my trains can carry it. Trains are on the go a lot more and never standing still.
2 Questions.
1) Do other people think this is actually beneficial to your profit? (since cargo is delivered more quickly)
2) How to implement this NICELY. Currently, i made a fn 'ShouldTrainLeave' that returns true when another train with space for the same goods is waiting at the station. This only when the loading patch is turned on.
I check this function where also the OF_FULL_LOAD is checked.
I actually think this just replaces the load patch, since now never an 'older' train for the same cargo will be waiting at the station.
I also wanted to be able to turn off this behaviour per train, so i now used the nonstop flag in the orders to enable this (since i don't usually need nonstop on my trains) but of course, this is not the right way.
Please, your thoughts about this!
btw: is there a good reason that ottd is c and not c++? portability?

Posted: 25 Aug 2005 11:18
by bobingabout
i think i liked the way it worked before better.
if a train leaves as soon as 1 arives, then if theres a trafic jam on a large network, all 10 trains could arive at once, and leave instantly because the others come in, only the last 1 gets filled, then the station is sat there for a year with no trains.

its not something i'd want to use. although, others might.

if 1 train full loads before another starts loading anyway, which it does, then if 2 arive at once, 1 full train will leave before the next starts loading, giving a constant even stream of trains, if you want them to load faster, just remove a carrage or 2...

Posted: 25 Aug 2005 11:30
by boekabart
I agree that it will only work nice if the trains are evenly spaced.
Question is, will they ever get evenly spaced with my patch running, like they do with the old patch running.
How to improve the patch so that we retain the 'train distribution' effect of the improved loading patch; yet avoid having too many trains waiting at the station (possibly blocking it for other cargo too...) Leave only the emptiest 2 trains?? I have to try this, to see if this is better.

Posted: 25 Aug 2005 13:12
by Nanaki13
I think it would be better like this:

A station has 4 platforms.
There are 4 trains in it, full loading
When train nr 5 is waiting to enter the station then
train nr 1 leaves making room for it.
When train 6 comes, train 2 leaves and so on.
That way the station is always full but never locked.

Posted: 25 Aug 2005 13:30
by bobingabout
yes, that is a better idea. but how does train 1, or whatever know when theres a train trying to get in?

Posted: 25 Aug 2005 13:30
by boekabart
@Nanaki13: I think that is very hard to code.... Maybe better to do it then when all platforms are full?

Posted: 25 Aug 2005 14:16
by Pixel du Rezo
I've started to code such a patch a few weeks ago...
It works fine, but there was no GUI... All settings where made in the source code, and since the first patch, I never had some time to continue this project...

The difference was that I also add a minimum load-percent before the train should leave.

So, evene if a new train with the same cargo arrives at the station, the first one won't live until the minimum load-percent.

What I must add to make my patch useable is the GUI..
But those days, I can't find times to make it... maybe, you could add this idea to your patch.

Posted: 25 Aug 2005 17:05
by Nanaki13
boekabart wrote:@Nanaki13: I think that is very hard to code.... Maybe better to do it then when all platforms are full?
That's what i meant.
When all platforms are full and there is a train waiting to get in, the first one that went into the station should leave. FIFO.
Or let's just say, the one with the most cargo should leave, coz it's going to be the first one most of the time anyway.

Posted: 26 Aug 2005 07:20
by Manar
But it's very hard for the program to know when there's a new train which wants to come into the station. A simple compromise is to have the most fully loaded train leave once a train rolls into the last free platform. Not entirly optimal, as you'd be keeping a single free platform open for whenever a new train arrives, but you'd get a steady flow of trains, and it would work for any size of station.

Ehm, except single platform stations, I suppose. Or too large stations where having a single platform open isn't enough to handle the flow of incoming trains. How about leaving the train orders as they are, and setting on the station how many platforms should be kept open?

Posted: 26 Aug 2005 07:41
by boekabart
Manar wrote:How about leaving the train orders as they are, and setting on the station how many platforms should be kept open?
This actually sound like a good idea, put a flag in the stations (i guess there's already some room for this in code) that there should always be a platform kept free. This also solves a probably well known problem: 3 goods trains waiting at a station, but no goods available because the grain train cannot come in :-(

I'm going to take a look at the feasability and workability of this. Any suggestions on which train should leave first? The fullest or the one with the least empty space? What in case there are 2 coal trains and 1 ore train waiting, always let a coal train leave or just the fullest even if that is the ore?

Posted: 26 Aug 2005 17:10
by Manar
A bit complicated, but this should work in all cases:

1. For every cargo-type, add up the total cargo loaded.
2. Select the cargotype of which the most has been loaded.
3. Select all trains which can carry that type of cargo.
4. Select the train with the least total remaining space.

I think this is the most balanced for loading of different types of cargo, and sends on the train which is closest to achieving the profit it would get otherwise. In the last step you need the least total remaining space, so trains carrying several types of cargo won't always leave first.

Posted: 28 Aug 2005 10:45
by SirkoZ
There is already a more configurable patch done, it just needs updating:
LINQ.

Posted: 28 Aug 2005 21:11
by boekabart
I found out myself that in some cases the thing with 'the fullest of 3 trains leaving' is not good, especially when they are trains which are waiting for manufactured cargo. I had 3 steel trns waiting in a station, and a lot of ore coming in (more than 3 trains full in fact) so the steel trains should have stayed and wait, but didn't, so a train ran almost empty and steel was left waiting.. Not good. Maybe i just should tweak the trains lengths...

Posted: 28 Aug 2005 21:28
by Sacro
Anyone who wants gui's doing or anything post your patch, and i'll see if i can implement one for you

Posted: 29 Aug 2005 11:53
by SirkoZ
Well - Sacro - please update the patch I had linked in the upper post and post the update in its topic. :)

Posted: 30 Aug 2005 08:31
by bobingabout
i'll ring him when i get home.

Posted: 30 Aug 2005 09:26
by SirkoZ
:)

Posted: 30 Aug 2005 20:37
by Sacro
Right, i've got your patch, and the latest nightly, so i'll take a look and see whats going on :) , is there anything in particular needs doing?

Posted: 30 Aug 2005 21:10
by SirkoZ
Well - I just thought if you could bring it "up to speed" - make it compatible with the latest nightly and fix some potential issues in code, if there are any... When updated, it'll be included in the latest "Integrated nightly" build. 8)

Posted: 01 Sep 2005 12:38
by Sacro
SirkoZ - i can do that for you.

Pixel du Rezo - would you like to post your patch, and then maybe that can be used as well