I Know It Can Be Done, But I Don't Know How To Do It!

Ian_Coleman

New member
I want to program an AI train so that it arrives at a terminus, and the loco uncouples from the consist.
Then a second loco which is waiting in a nearby siding moves to the station and couples to the consist, which then makes its way to its new destination.
The first loco then moves to the nearby siding and waits so that in its turn, it can do the same thing again when the next train arrives at the terminus.

Incidentally, although uncouple is in the list of available commands and the box next to it is ticked, when I am programming an AI driver, the command is not there. Does anyone know how to get it back?

Ian
 
Ian,
The Decouple command that was originally included with TRS doesn't appear in the list of commands when setting up the AI in Surveyor because the command was written to act on the names of rolling stock on the layout at the time, and so couldn't be used in Surveyor that way.

That's why I wrote the UnCouplez and UnCouplezFrom commands, so that they can be used in Surveyor to set up automatic freight operations.

UnCouplez will decouple all locos at the front of the train from the rest of the train (including tenders), and UnCouplezFrom will allow you to decide numerically where to decouple in the train.
These are the commands that Bloodnok is referring to in the post Mike has linked to, and they are both built-in to TRS2006 or available on the DS for TRS2004.

Have fun,
Smiley.
 
Re above

I've studied Bloodnok's thesis and found it very helpful. I downloaded the necessary orders and set everything up. However, I can only get the sequence to run once, and I was hoping to run it continuously.

But there seems to be no way of getting Loco 1 complete its journey, then become loco 2 and then becomming Loco 2 again, and so on!

I'm still sure it can be done, but I can't work out how to do it!

Ian
 
You should be able to run it continuously using Bloodnok's theories. I believe some others have managed.

Perhaps a post in the UKTrainz thread will yield results?

Mike.
 
Ian,
it depends on if you want to run a strict timetable like Bloodnok does, or whether you just want continuous trains without worrying about timetables.

If you want to do it like Bloodnok, you should note that the trains that are generated by the portals not only have the commands for bringing the service into the terminus, uncoupling and pulling into the stable area after the coaches have been taken by the other engine, but it must also have the commands that acts as the stabling engine when the next loco brings the next service.

So a portal generated loco would have commands like this pseudo code:

Portal Generated Loco: .../Arrive at terminus/uncouple/wait for coaches to be taken by other loco/drive to stabling point/wait for minute 20/connect to coaches/drive off with coaches/......

In the above example, the commands that are not underlined are the loco acting as the arriving loco, and the underlined commands are the loco acting as the departing loco.
This means that every hour this sequence will take place again (the newly created portal train will contain the same commands, and the old loco waiting at the stabling point will still be waiting on the second half of the commands).

BUT, as Bloodnok pointed out in his post, to start the sequence off, you need a loco waiting at the stabling point with only the second half of the commands (the underlined parts) because when you first start the session the portal will only create the one train and you need the second on there waiting to start with.

From what I can read from his post, he sets up 4 different trains from different portals so that he can have steady traffic every 15 minutes rather than every 1 hour, and this also requires a special portal that allows you to state what time the trains are created by the portal.

If you didn't wan't to bother with timetables, and only wanted the same two locos to continuously swap the same coaches after their runs, then that's even easier.
You just need to have each train waiting on the other to hit triggers rather than using the "wait for minute" command, so that the stabling loco is waiting for the other loco to arrive at the platform before it goes to get the coaches off it, and the other loco is waiting for the stabling loco to have cleared the station and junctions before it goes off to the stabling point to wait for it's return.
Note that for this second type of operation, you must set up one loco with the commands the normal way around (go to station/wait/go to stable point/wait/collect coaches/depart) and the other loco has to be waiting at the stabling point from the start of the sesssion (wait/collect coaches/depart/go to station/wait/go to stabling point).
Also, you need to add the station stops for each loco between departing and arriving back at the station.

Hope that helps.
It's easy enough once you get your head around the logic.
If it's the second type of operation you're after, I can knock up an example to send you if you like.
The first example is not something I use personally, although it would also be easy enough to set up.

Smiley.
 
Hi Smiley,
It's the second type of operation I'm after. I can see that it's simple enough in theory, but I just don't seem to be able to get it to work. I'm obviously doing something stupid!
I'd like to take advantage of your kind offer to knock up an example for me if you have the time.

Ian
 
Hi Ian.
Sure, I'll get something knocked up in surveyor tonight.
You'll need the "couple at trackmark" command.
The DS is down for me right now (Wow, the DS down at the weekend!! :D ), so let me know if you need this too.

Smiley.
 
Ok, I've just put something together, and I've been watching it for 30 minutes without any problems, so I can pack it up and post a link here.

The only thing is that it was created in TRS2006 so it won't be any good in TRS2004.

Let me know tomorrow (Monday) if you're using TRS2006 and I'll post a link to the layout and session here.

If you're using TRS2004 then I'll post a map of the layout and detailed instructions for each of the 2 locos, as well as info on the triggers/trackmarks required, and their radii.

Either way, it should be useful for what you want.

Smiley.
 
Ok, here's how I got the two locos working in the way that Bloodnok described in his post.

Here's the map of the layout, broken into 2 parts so that it complies with allowed screen sizes on this forum :rolleyes:.

auto1.jpg


auto2.jpg


The green T's are obviously Triggers and the red dots are Trackmarks, and most of these should have their radii set to between 5 and 10 (although trial and error with their positions will also get the results you want).
Don't worry about the radii for the moment. Leave that for when everything else is set up and the locos get stuck for some reason.

Make sure to put buffer stops at the end of the stabling spur, and also at the end of both prongs of the "Y".

Now, if you've added all the trackmarks and triggers and named them, and you've added loco 1 with a few carriages and loco 2 in the correct place, you should edit the session and add the following commands to them.

Alastair (Loco 1)

>> Drive to Station
>> Load
>> Uncouplez
>> Wait for Trigger "clear" to be triggered by "loco 2"
// waits for other loco to collect coaches and pull clear of the station
>> Drive to Trackmark "stable" // drives this loco into the stabling point out of the way
>> Wait for Trigger "arrive" to be triggered by "loco 2" // waits for the other loco to arrive back at the station
>> wait 20 seconds // just to give the train at the platform enough time to load passengers and uncouple
>> Couple at Trackmark "couple" // drives this loco up to the trackmark "couple" and couples up to the carriages in the process
>> Drive to Trackmark 1 // see next command
>> Drive to trackmark 2 // This command and the previous one use the "Y" to turn the train around so that it pulls into the station loco first.
>> Repeat // don't forget to add the repeat command


Adair (Loco 2)

>> Wait for Trigger "arrive" to be triggered by "loco 1" // waits for the other loco to arrive back at the station
>> wait 20 seconds // just to give the train at the platform enough time to load passengers and uncouple
>> Couple at Trackmark "couple" // drives this loco up to the trackmark "couple" and couples up to the carriages in the process
>> Drive to Trackmark 1 // see next command
>> Drive to trackmark 2 // This command and the previous one use the "Y" to turn the train around so that it pulls into the station loco first.
>> Drive to Station
>> Load
>> Uncouplez
>> Wait for Trigger "clear" to be triggered by "loco 1"
// waits for other loco to collect coaches and pull clear of the station
>> Drive to Trackmark "stable" // drives this loco into the stabling point out of the way
>> Repeat // don't forget to add the repeat command

Now, you should be able to run this session and watch as one train pulls into the station with a few carriages, opens it's doors to load/unload, closes it's doors, and uncouples.
Then the train in the stabling area will come and collect the coaches, and leave the station with them. Once the line is clear, the loco that's left in the station will pull into the stabling area and wait for the train to return with the carriages.
This process continues indefintely, with the locos taking it in turns to do each job.

If you have problems, you should probably make sure that the "stable" trackmark isn't too close to the buffers at the end of the stable point, otherwise it may never reach the trackmark area.
You should also be aware that certain signalling may stop this working.
As a test you should place a signal in the stable spur, that in proto situations would keep the loco in there until it is safe to leave.
This will probably stop the session from working, as the loco in there isn't able to pass the signal when using the "couple at trackmark" command.
Removing the signal allows the session to work, and doesn't really take anything away from the layout.

That should be it.
There should be enough info there to set up any amount of automatic traffic that you want on your layouts.

BTW Ian, you don't need the Change Direction command like I said you did in the Email.
I usually use it because the AI easily gets confused with automatic operations, but this example is simple enough that the AI seems to cope with it.
It's still one of the 4 "must-have" commands for auto running, IMO.
They are "UnCouplez", "UnCouplezFrom", "Couple at Trackmark", and "Change Direction".

Good luck,
Smiley.
 
Smiley, I just thought - any special requirements re signals, or can I just place signals in what I consider to be appropriate places?

Cheers,
Ian
 
Set it up, double checked that the commands were correct.
The first bit went perfectly, but when it was Alistair's turn to wait in the stable, the points on his stable line changed just in time to derail poor Adair who was approaching at the time!

I'll check over all the commands and also make sure that the triggers and trackmarks are correct.
Haven't got time at the moment, but I'm sure the problem is down to me and I'll try to sort it out later.

Ian
 
Sounds like the trigger radius on the "arrive" may be too big, or the trigger isn't far enough down the end of the track.
Also, it could be that the "stable" trackmark radius needs reducing, so that the loco going into the stable area goes further into the spur, and further away from the points.

I would recommend making the radii on both the "stable" trackmark and the "arrive" trigger something like 2.
This will mean the loco will pretty much touch the trigger/trackmark, and will avoid the loco still having an influence on the junction.

I love this kind of tweaking when setting up a session.
It's worth it when it finally works as it should. :D

EDIT: Just read your Email, and the problems definitely do seem to stem from trigger and trackmark radii being to high (the default is 50).
If you are finding that the loco that should go into the stable area is closely following the train that leaves the station, then that means that the train leaving the station is hitting the "clear" trigger, because the solo loco can't/won't move until it gets the message saying as much.
Moving the trackmarks and triggers further away might seem like it should work, but if they still have their default 50m radius then they are still going to be triggering too early.

Let me know if reducing the radii of the triggers/trackmarks solves your problems (I'm pretty sure it will).

Good luck,
Smiley.
 
Last edited:
Hi Smiley,
I spent quite long time yesterday looking through the manuals to try and find out how to adjust the radii of the triggers. Maybe I'm just dim, but I can't find any information re radius adjustment.
Looks like I have to ask for your help again!

Ian
 
I Know it can be done but dont know how to do it.

Ian,
it depends on if you want to run a strict timetable like Bloodnok does, or whether you just want continuous trains without worrying about timetables.

If you want to do it like Bloodnok, you should note that the trains that are generated by the portals not only have the commands for bringing the service into the terminus, uncoupling and pulling into the stable area after the coaches have been taken by the other engine, but it must also have the commands that acts as the stabling engine when the next loco brings the next service.

So a portal generated loco would have commands like this pseudo code:

Portal Generated Loco: .../Arrive at terminus/uncouple/wait for coaches to be taken by other loco/drive to stabling point/wait for minute 20/connect to coaches/drive off with coaches/......

In the above example, the commands that are not underlined are the loco acting as the arriving loco, and the underlined commands are the loco acting as the departing loco.
This means that every hour this sequence will take place again (the newly created portal train will contain the same commands, and the old loco waiting at the stabling point will still be waiting on the second half of the commands).

BUT, as Bloodnok pointed out in his post, to start the sequence off, you need a loco waiting at the stabling point with only the second half of the commands (the underlined parts) because when you first start the session the portal will only create the one train and you need the second on there waiting to start with.

From what I can read from his post, he sets up 4 different trains from different portals so that he can have steady traffic every 15 minutes rather than every 1 hour, and this also requires a special portal that allows you to state what time the trains are created by the portal.

If you didn't wan't to bother with timetables, and only wanted the same two locos to continuously swap the same coaches after their runs, then that's even easier.
You just need to have each train waiting on the other to hit triggers rather than using the "wait for minute" command, so that the stabling loco is waiting for the other loco to arrive at the platform before it goes to get the coaches off it, and the other loco is waiting for the stabling loco to have cleared the station and junctions before it goes off to the stabling point to wait for it's return.
Note that for this second type of operation, you must set up one loco with the commands the normal way around (go to station/wait/go to stable point/wait/collect coaches/depart) and the other loco has to be waiting at the stabling point from the start of the sesssion (wait/collect coaches/depart/go to station/wait/go to stabling point).
Also, you need to add the station stops for each loco between departing and arriving back at the station.

Hope that helps.
It's easy enough once you get your head around the logic.
If it's the second type of operation you're after, I can knock up an example to send you if you like.
The first example is not something I use personally, although it would also be easy enough to set up.

Smiley.
I to have thisa problem not bothered about timetables so the second type you mention would suit me could you also knock me up an example as my grey cells are not very good these days at anything logic old age im afraid many thanks smiley and up the Gunners my team also first ever went to hibrury in 1936.
 
Hi Ian.
The tools for adjusting the radius of the triggers and trackmarks can be found by clicking the advanced button at the bottom of the trackmark mode on the track panel:

adjust.jpg


Hey Bertie.
If you have TRS2006 SP1 I can make the layout and session available for you to download, but if you're using TRS2004 then the above guide is the best I can do, as the layout/session won't work with it.

I'll be adding the above guide to the tutorial section of my site in the next couple of days, along with the download for TRS2006, so if you can use it you can grab it then.

BTW, next season is Arsenal's season. :)

Smiley.
 
Back
Top