Jump to content
 

Designing a basic random number generator for shed ops


Recommended Posts

Ok, so this one feels a bit niche, to say the least.

 

I want to design a simple program to help replicate the challenge of managing operations in a small TMD layout.

 

What I want it to do is to pick a loco from those not already on shed, then generate a random number that signifies, appropriately weighted, whether it needs fuel, inspection, Cat A/B/C/D/E work, or has failed. Then it should remove that loco from the pool, adding it to the 'on shed' side of the list, wait a predetermined amount of time, and repeat until nothing is 'off shed'. Ideally, there'd be an option to move locos back from 'on' to 'off' as they are sent back out for duties, but that's negotiable.

 

The problem is I'm not great with programming of this sort, and I don't really know where to start. Does anyone have any experience with this, or use a similar system themselves?

 

I should clarify that I'm not looking for a program that moves trains, just something that tells the operator where a loco needs to be stabled and for how long.

 

Many thanks

Edited by Carver Bridge TMD
Clarification line
Link to post
Share on other sites

Have you considered using Excel?

 

Loads of guidance and tutorials online of how to do things in it, and I know you can use it to create a random number generator. You can also hide or lock content, and create a clean looking worksheet for use by operators, with the clever bits hidden on another worksheet. Hiding or locking that sheet means data can't be deleted or formulae broken accidentally.

 

Jo

  • Agree 2
Link to post
Share on other sites

I toyed with a random number generator to generate goods train consists, there's plenty available free on Google Play (and probs other app marketplaces).

 

Can't remember what I tried but you could request a random number, say, in the range of 6 to 15 for the number of goods wagons, and there were lots of other capabilities.

Link to post
Share on other sites

  • RMweb Premium
4 hours ago, Carver Bridge TMD said:

Ok, so this one feels a bit niche, to say the least.

 

I want to design a simple program to help replicate the challenge of managing operations in a small TMD layout.

 

What I want it to do is to pick a loco from those not already on shed, then generate a random number that signifies, appropriately weighted, whether it needs fuel, inspection, Cat A/B/C/D/E work, or has failed. Then it should remove that loco from the pool, adding it to the 'on shed' side of the list, wait a predetermined amount of time, and repeat until nothing is 'off shed'. Ideally, there'd be an option to move locos back from 'on' to 'off' as they are sent back out for duties, but that's negotiable.

 

The problem is I'm not great with programming of this sort, and I don't really know where to start. Does anyone have any experience with this, or use a similar system themselves?

 

I should clarify that I'm not looking for a program that moves trains, just something that tells the operator where a loco needs to be stabled and for how long.

 

Many thanks

 

10 minutes ago, Dagworth said:

Buy a pack of playing cards!  Ask @Clive Mortimore

 

Andi

As Andi suggest a pack of cards.

 

My old large depot Hanging Hill had the following, at a normal show there would be around 40 odd locos,

An Ace, any colour, was for a fuel train, swapping the empties with new full tank wagons.

A black card turned over meant a loco coming on shed and was refueled, and A or B examination. If it was a picture card the loco that had been on the fuel point the longest was moved off into the shed building for a repair or C, D or E exam.

Some black cards had a meaning, 6 was a double headed pair, and 8 was coupled to a brake tender.

A red card turned over was a loco off the depot from the loco sidings. A red picture card released a loco form the shed building, repair/exam done so to the loco sidings, with a different loco going off to perform it's next duty. Again 6 was a double headed pair and an 8 the loco had to find a brake tender before leaving.

A joker was the stores train, swapping the various stores vans and wagons.

 

For my small stabling point Pig Lane where I only have 12 locos,

An ace is the fuel train and a joker the stores train.

Each loco has a card number or picture irrespective of suit. If the loco is on shed it trundles away to its next duty. If on the stock table it is placed on the track and makes its way to the fuel point.

 

  • Like 4
Link to post
Share on other sites

There's a site that generates randomised deals for bridge, if you don't want to shuffle the cards.

http://playbridge.com/

Double the fun, you can use it to both generate the required layout moves, and play a devastating squeeze to obtain a small slam from a game hand.

Edited by 34theletterbetweenB&D
Oops forgot the link, too busy winning the hand,
  • Funny 1
Link to post
Share on other sites

  • RMweb Gold

Downloaded free app to my phone, the range can be set, and it is set to 0-100.  The first number generated is the percentatge chance of an event occuring during today's timetable; it is then up to me to decide whether it will or not.  Then a further number decides what the event is from a list with allocated numbers (hot axle box on mineral train, wagon/van on mileage siding not unloaded, auto-gear on loco not working, &c).  The third number delineates what time of day the incident takes place, and the fourth the actual working affected.  Arbitrary decisions on further details are then made according to how much fun I want to have with it; a major snafu such as a fusible plug mishap will put the timetable for the branch out for the whole rest of the day, and in the 50s trains were not cancelled as readily as they are nowaday, the ethic was to keep the service running as best you could whatever the delay.

 

Serious delays of the sort that affect manning and require relief crews to be found by Control are probably rare on shortish branch lines like Cwmdimbath, but on main line could have the phones running red hot in Control as diversionary routes were found, pilots and relief crews arranged, connections held and so on.  For locomen, guards, and signalmen 12 hours rest was mandatory before they could book back on duty after their last shift, and this meant that manning problems might easily carry over into the following day.  A landslip on the branch trapping a train behind it would be fun; the engine would need to be kept in steam and the crew relieved, possibly by taxi in the days before traincrew minibuses, at regular intervals, and possibly food arranged for them.  I once got stranded on a Sunday ballast job that overran badly, and was sent a packed lunch from the Buffet at Cardiff Central, cold chicken portion, cheese roll, fresh apple, bottle of light ale.

Link to post
Share on other sites

  • RMweb Premium

What you describe isn't particularly difficult, but it does involve quite a lot of steps. Just to take the first thing:

10 hours ago, Carver Bridge TMD said:

pick a loco from those not already on shed

means creating a list of locos, counting them (to know the range for the random number generator), generating a random number and finally selecting a locomotive on the basis of the random number.

 

You could do it in Excel, as @Steadfast suggested, if you have some way of running Excel during your operating sessions. In many ways, Excel isn't ideal. It has a habit of trying to convert text into numbers, which often gives problems with leading zeros (is your layout TOPS era, with class 08s, perhaps?). It's not very good at waiting for a set period of time. It is difficult to stop or pause a program when it is running, and if you are using the computer for other things at the same time, the running Excel program will tie up resources. None of these are show-stoppers, and Excel does have some great advantages: you are likely to have it already, you are probably already reasonably familiar with it, and it is pretty quick to get things up and running.

 

The key thing is what you want the display to look like. Presumably you will have a list of off-shed locos (in column A, perhaps). How do you want the on-shed locos to be displayed? Perhaps they aren't displayed at all. Perhaps you will have a list of locos. You might then have the location/activity alongside. Perhaps if the activity is time-related, the remaining time might auto-update (this is fairly easy to do). Or perhaps you will have a list of locations, and place each loco against the location.

 

How do you want "decisions" to be displayed? If you have a list of on-shed locomotives with locations/activities, then the loco number could simply move from the off-shed list to the on-shed list with the appropriate location/activity. This could be reinforced with a popup. Or perhaps you want a list of actions (new actions added at the top, perhaps), as a record of what has happened so far. Or some combination of these things.

 

If you think that Excel might be suitable, then I suggest you create a template for the interface and post it on here (a screenshot will be fine). I would be happy to help you with the coding. In your template, leave room for a Start button (this can be the size of a default cell, but it would probably look better being two rows high).

  • Like 1
Link to post
Share on other sites

  • RMweb Gold

If you wrote a simple little bit of Javascript you could run it on any browser on any device, either served from a server or from local storage.

Start off with something simple and then improve the UI over time.

 

  • Like 1
Link to post
Share on other sites

You don't need to program anything, just use dice, they come in all shapes and sizes these days.  All you need to do is make a table for each activity/road/failure etc and write it on a table and assign a dice number to it.  You can even add a rare combination so a loco fails and has to be assisted back to a service road etc.

 

  • Agree 3
Link to post
Share on other sites

  • RMweb Premium
34 minutes ago, Boris said:

You don't need to program anything, just use dice, they come in all shapes and sizes these days.  All you need to do is make a table for each activity/road/failure etc and write it on a table and assign a dice number to it.  You can even add a rare combination so a loco fails and has to be assisted back to a service road etc.

 

Sounds good but when I have used a dice system the public at shows can't see what is happening.  Unless the dice falls on the floor.

With my card system I simply put the card in a box where the public can see what I am doing.

image.png.e85aa192132d0000cc8c4cfa7291d4a5.png

 

Or they can see the card on the floor.

image.png.46c69574444374933598bafffef9ad99.png

When I miss the box.

 

https://www.youtube.com/watch?v=e4EL_MRnT8o&t=40s  For a quick video on how I operate Pig Lane.

 

I suppose with a computer generated random system it could be linked in with the controller so when it chooses a loco, the said loco goes through its start up procedure automatically and is ready to roll when the operator wants to move it. 

  • Like 6
  • Round of applause 1
Link to post
Share on other sites

30 minutes ago, Clive Mortimore said:

I suppose with a computer generated random system it could be linked in with the controller so when it chooses a loco, the said loco goes through its start up procedure automatically and is ready to roll when the operator wants to move it. 

Except if that loco is behind another loco that hasn't started up as well to move out of the way.  Gonna need some AI to sort that one.

 

And I've seen you cheat at cards 🤣

  • Interesting/Thought-provoking 1
  • Funny 2
Link to post
Share on other sites

  • RMweb Premium
20 minutes ago, woodenhead said:

Except if that loco is behind another loco that hasn't started up as well to move out of the way.  Gonna need some AI to sort that one.

 

And I've seen you cheat at cards 🤣

Me cheat?

 

No matter which system one uses to generate loco moves on a depot layout it must be one that works for the operators and is fun to play with.

  • Like 2
  • Agree 3
Link to post
Share on other sites

Basic is a convenient if old-fashioned programming language for this sort of thing.

The first thing I did with my BBC Micro was to modify the Clock program that came with it (written in Basic) to a fast clock (8 times normal speed) for running a model railway to a timetable.  I also wrote my own spreadsheet system for maintaining an inventory of rolling stock.

Microsoft used to come with a version called qBasic.  This was extremely useful and I wrote a number of program using this for various purposes.  One was to operate a full size block instrument by offering train using the standard bell codes, and operating the dials.  It could also generate random emergency codes.  The more difficult part was getting it to interpret bell codes sent to it using a tapper.

It can still be used with Windows running a DOS box.

 

It can of course be written using other programming languages, it's really a question of what you have readily available and what you have familiarity with as there is a learning curve with all progamming languages.

 

1 hour ago, Clive Mortimore said:

I suppose with a computer generated random system it could be linked in with the controller so when it chooses a loco, the said loco goes through its start up procedure automatically and is ready to roll when the operator wants to move it. 

 

49 minutes ago, woodenhead said:

Except if that loco is behind another loco that hasn't started up as well to move out of the way.  Gonna need some AI to sort that one.

 

This could be done if you develop an interface to software like iTrain - which is a better piece of software than any AI system I've yet seen..

Link to post
Share on other sites

1 minute ago, Michael Hodgson said:

This could be done if you develop an interface to software like iTrain - which is a better piece of software than any AI system I've yet seen..

We don't play with AI, we play with large language models.

 

As a developer I am confident there are many ways to skin this particular cat, but I used AI because as you'll probably know it is the answer to every question these days and my days are numbered, even more so since Microsoft announced their latest product that is claimed to removed the developer from the development cycle......

Link to post
Share on other sites

2 minutes ago, woodenhead said:

We don't play with AI, we play with large language models.

 

Don't give me AI.

 

Yesterday I wanted to hang out the washing if the weather was going to hold.

Alexa told me it would start raining at 12pm. 

I've always understood there was no such time, there's 12 noon and 12 midnight, given the meaning of the Latin abbreviations. 

And I'm wary of those times having had to fix Cobol programs that had been specified for a clock running from 0101 to 2460 hours.

So I asked Alexa "What is pm?" and it told me that was currently Rishi.

OK, fair enough I suppose, so I rephrased it "When is pm?" 

It told me that 8pm started on 12th March 2023 at 4am !!

  • Like 1
Link to post
Share on other sites

1 minute ago, Michael Hodgson said:

Don't give me AI.

 

Yesterday I wanted to hang out the washing if the weather was going to hold.

Alexa told me it would start raining at 12pm. 

I've always understood there was no such time, there's 12 noon and 12 midnight, given the meaning of the Latin abbreviations. 

And I'm wary of those times having had to fix Cobol programs that had been specified for a clock running from 0101 to 2460 hours.

So I asked Alexa "What is pm?" and it told me that was currently Rishi.

OK, fair enough I suppose, so I rephrased it "When is pm?" 

It told me that 8pm started on 12th March 2023 at 4am !!

From the company that brought us till free shopping powered by 10000 Indian remote checkout assistants. 🤣

  • Funny 2
Link to post
Share on other sites

3 hours ago, Clive Mortimore said:

Sounds good but when I have used a dice system the public at shows can't see what is happening.  Unless the dice falls on the floor.

With my card system I simply put the card in a box where the public can see what I am doing.

image.png.e85aa192132d0000cc8c4cfa7291d4a5.png

 

Or they can see the card on the floor.

 

When I miss the box.

 

https://www.youtube.com/watch?v=e4EL_MRnT8o&t=40s  For a quick video on how I operate Pig Lane.

 

I suppose with a computer generated random system it could be linked in with the controller so when it chooses a loco, the said loco goes through its start up procedure automatically and is ready to roll when the operator wants to move it. 

Or a dice tower, you could probably get a railway themed one, you drop the dice in the top and they roll down a slope and into a tray - you could make that interactive with the public?

  • Agree 1
Link to post
Share on other sites

  • RMweb Gold

I use an Android app called "Randomiser" to sort the order of wagons on my O gauge shunting micro.

 

Free to download, simple to use and completely random!

 

 

Link to post
Share on other sites

There used to be a program called Multimedia Builder from Mediachance, it was a very basic program to make your own programs - originally meant to make your own DVD menus. When I was a kid I used it to create a game of chance based on random number generation. It's really hard to find a download for it these days, but I've just managed it and will see if it still works on Windows 10/11. Might be a good option for creating a tailored solution to your needs. The free version just has a little watermark at the bottom of any app you make syaing it was created with the free version, it's otherwise unrestricted (or was when I last used it). 

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...