NOTE: I've tested the game in Netscape Navigator, Firefox, Safari, and AOL's browser. It works best in Netscape and Firefox.
To start the game, click "Start Game." This sets all parameters to their starting state.
To see something begin to happen, click "Advance Trains", which will advance the time clock to the point of the appearance of the first train.
About the game
This game simulates the dispatching of a double-tracked, bi-directional signaled stretch of railroad with full crossovers evenly spaced along the entire 16 block division. This theoretical railroad is represented on screen by four rows of 8 blocks each. The western portion of the division is represented by the first two rows, with the top row for track 1 and the bottom row for track 2. The eastern portion is represented by the bottom two rows, again with the top row for track 1 and the bottom row for track 2. The two blocks on the right end of the top two rows are next to (west of) the two blocks on the left end of the bottom two rows. I have attempted to label these blocks and tracks carefully for clarity. The numbers above pairs of blocks that don't have a written word in bold indicate the block number, numbered from west to east.
Realistic and non realistic aspects
There are no sidings, but sidings are effectively simulated at each end of the division, since trains in the last block before leaving the division are not affected by trains that should in theory be in the block ahead of them which isn't shown on the display. Also, since there are no trains on the track at the start of the game, the first few trains can run without interference. I also recognize that the theoretical stretch of railroad represented would in actuality be a stretch of double track about 140 miles long with crossovers spaced at precise intervals, with no sidings, yards, slow orders, or other variations. Few if any stretches of railroad fit this description. Finally, you can't put more than one train on each track between sets of crossovers. In real life, you would be able to put several trains in this space, thus allowing trains to advance much further than they can in this game. Based on track layout and train symbols used, the closest approximate real-life comparison, including borrowed and invented train symbols, would be the double track former New York Central/Conrail route following the Mohawk river through central New York state.
This game does, however, present the opportunity to practice routing trains around each other, holding trains for other trains, and even demonstrating a theoretical computerized train dispatching system. You could try your skill at certain dispatching techniques, or explore the information displayed by this game to see what kind of information would be most useful for an actual train dispatching system. For example, I found I had significantly reduced delays when I started displaying how many minutes a train had remaining before being penalized for delays. I'm sure there are other similarities and differences to a real world dispatching system. I would be interested in discussing them.
What the game does/Starting a round
Nothing happens until you click "Start Game" or "Advance Trains."
Start Game clears everything from the display so that the game isn't confused by old data from a previous round (unless Scenario data has been pasted into the "Next Train" text box.
Scenarios: You can play a previously saved scenario by pasting a saved list of trains into the "Next Train" text area, then clicking "Start Game." See "Show History" below for saving a list of trains.
Advance Trains advances the game one minute at a time until one of several things happen. Each time you click this button, the game advances until a train appears in the "Next Train" box or when a train is ready to move, or its request to be crossed over is denied. When the game stops, trains that are ready to move will have the box they are in turn green if there are no delays, or red if they have used up more than the alotted time in the current block. The game will also stop if there are no trains on the board and train frequency is set to 0. The game does not stop when a train is ready to move but cannot move either because there is no place for it to go, or it has been allowed to cross over, or it is being held, unless it has been holding for more than 20 minutes.
Trains will advance to the next block on the same track if the block is empty, or request to be crossed over if the next block on the same track is occupied and the next block on the other track is empty and not lined. If the train cannot advance to either block, it will stay where it is. The game will not allow trains to crash into each other.
The advancement of trains is processed from west to east, starting with the west end of track 1 and ending with the east end of track 2. This means that on track 1, eastbound trains ready to move east will not be able to do so unless there is a block ahead of it on one of the two tracks that was also free during the previous minute. This causes eastbound trains traveling as close behind each other as possible to advance in a staggered fashion, with one train advancing to the next block in one minute and the next train advancing to the block just vacated by the first train in the following minute. The same is true on track 2, except if the next block on track 1 becomes available in the same minute the train is ready to move, in which case, the train will ask to be crossed over to track 1. Westbound trains traveling as close behind each other as possible can both advance to the next block at the same time, however, a westbound on track 1 will wait until the minute after the next block on track 2 becomes available if its only choice is to cross over.
What the game doesn't do
The game doesn't judge your dispatching ability (or lack thereof). It doesn't keep any scores or records of past performance (only the current session data is displayed). And it doesn't prevent gridlock (see "Houston, we have a problem" below).
Train Generation
This is a busy stretch of railroad, with a default of approximately 4 trains per hour, or 96 trains per day, and far more Amtrak trains than on any stretch of a busy freight railroad. You can adjust the frequency, but not the mix of trains. Train direction and speed are chosen randomly from a defined range of possibilities. Train symbols are assigned based on speed and direction, except for coal trains. Coal train symbols are assigned based on speed only, so you may have the same symbol coal train going in opposite directions. When a new train is generated, its information is placed in the "Next Train" box and the "Next Train" box turns green. The next time you click "Advance Trains" the game will attempt to put the new train at the appropriate end of the display based on the train's direction. If the train cannot be placed on the board, one minute will be subtracted from the time the train takes to transit a box. When this number reaches 0, the "Next Train" box turns yellow, warning you that if the train is further delayed, it will begin to acrue delay minutes on the next click of "Advance Trains." If this number goes negative, the "Next Train" box turns red, and you will begin to acrue delay minutes before the train even gets on the board! The game will not generate more than one new train per minute, and will not place more than one train on the board per minute, but several new trains could be generated between when you click the "Advance Trains" button and the next time the game stops. When a new train is generated, the "Trains Waiting" field will be incremented by one. When trains are waiting to enter, there will be an attempt to get them on the board each minute, in addition to the possibility of the generation of yet another train in the same minute. If a train enters the display because a train is waiting to enter, and another train is generated, only one train will enter the display, but the "trains waiting" field will stay the same.
Fast trains and slow trains
The game provides a mix of passenger (Amtrak), trailer (van), auto rack, stack, mixed, and coal trains. Amtrak trains are scheduled to move fast, while the coal and mixed trains drag their feet. Auto rack and Van trains travel at speeds slower than Amtrak and faster than coal and mixed trains.
Train Interference and delayed trains
If you don't let a passenger or trailer train get around a slower auto rack, stack, mixed, or coal train, the slower train will delay the faster one. You are allowed a few extra minutes for such delays, with more allowed for the slower trains. Once those minutes are used up, you will be penalized for further delays, and all such delays will be totaled for as long as you continue to play the game. While there's currently no scorekeeping from one session to the next, challenge yourself to have as few delays as possible.
Houston, we have a problem...
If you simply agree to all requests to be crossed over, or aren't careful in your dispatching, you will probably end up with two eastbounds facing two westbounds. Since each of the four trains is waiting for one of the others to move to free a block for it to move to, and since trains can't back up, you are effectively facing gridlock. The game will still work, but the display will slowly be filled with trains, and the "Trains Waiting" field will start accumulating trains waiting to enter. This will quickly get boring. The only way out of this is to restart the game.
Dispatching the trains
Crossing and holding trains
With an incentive to actually dispatch the trains, both to prevent gridlock and to minimize delays, you'll need to tell trains to cross over even before it is absolutely necessary, or to tell a train to stay in the block it's currently in. There are two buttons provided for each block to do this, labeled "C" and "H." C asks if you want to cross the train over. H asks if you want to hold the train where it is. Click "OK" to confirm your action. "Cross" or "Hold" will appear in the block below the train information. In either case, the train will not advance to the next block without your permission. When the train is ready to cross over, it will ask for permission through a dialog box, and the train's square will turn yellow. Trains being held will continue to be held until you cancel the hold. You can cancel the hold or undo the crossover request by clicking either button, and you will be asked if you want the train to proceed.
When a train wants to cross over
A train ready to move that has been directed to cross over or can only cross over to continue to advance will request your permission to do so via a dialog box asking you to confirm the move. Also, the train's square will turn yellow, and the word "cross" will take the place of the symbol for the train making the request. If you have not directed a train to cross over but that is the only option it has, it will request to cross over every time you click the "Advance Trains" button" until it has been allowed to cross. This can get annoying when things are busy, but you can prevent it by "lining" the block the train is trying to cross to. See below "Line the block." Crossing a train to the other track charges that train with one minute of delay time. It does this by adding one minute to the time the train would normally take to pass through the next block. This also causes one minute to be subtracted from the extra minutes allowed for delays, even when all extra minutes have been used up and the number representing delays has gone negative.
Line the block
When no train is in a block, clicking on either button above that block will put the word "lined" into the corresponding block. This is useful when a train is approaching the end of the division, as an incoming train may block it's approach causing one or both trains to be delayed. However, if the end block is lined, this prevents a train from entering the district in that block, and thus gives the approaching train already on your screen what is effectively a clear signal. If a block is lined, you can unline the block by clicking on either button for that block. Trains already in the display assume any "lined" blocks are lined for them unless the train is trying to cross to the other track into a lined block. If you have specifically directed a train to cross over, it will still cross over into a lined block. Note: It is possible to prevent any trains from entering the district by lining up all four blocks at the ends of the district. This is useful if there are too many trains on the board, especially when they are close to leaving the board. But if there are no trains on the board, the game stops, as this would defeat the purpose of the game. The game will still continue to generate trains that want to enter, incrementing the "Trains Waiting" field.
Holding trains
You can hold trains in 3 ways: click the "H" button for the block the train is currently in until "Hold" is displayed before the train info, deny its request to cross over, or click "lined" in the block the train is trying to cross over to. If you have specifically directed a train to cross over, it will still cross over into a lined block.
Entering new trains
The "Next Train" information block displays the information for the next train that wants to enter. When a train appears in this block, the game will stop, the "Next Train" box turns green, and 3 radio buttons and a "Hold" button will appear. The radio buttons allow you to select which track you would like the train to take when it enters the display. The default is "Default track." For westbounds, this means track 1, for eastbounds, track 2. If the default track isn't available, the other track will be tried. If you select a track, the train will wait until that track is available before entering the board. It will not enter on the other track even if it is available. The hold button will hold the train until you click the "Hold" button again. These options are useful to help keep track clear for trains approaching the end of the board and can also reduce crossover moves the new train might otherwise have to make to get around a slower train ahead of it. There is an incentive to get the train moving though, as if the train waits in the "Next Train" box longer than the time it takes to travel through one block, it will begin to be penalized delay minutes. When the train has spent the number of minutes to go through one block but not more, the "Next Train" block turns yellow as a warning. Once delay minutes are starting to be penalized, the "Next Train" box turns red.
Trains, symbols, and the train info
Each train has a symbol and 4 character positions displayed in the block representing the current location of the train.
Symbols
The symbols are borrowed from Conrail symbols used on their Chicago line (former NYC) between Albany (Selkirk), NY and Chicago, IL. Amtrak symbols begin with "A" followed by letters representing its destination, including unusual places like Toledo, Indiana, Ohio, New England, Long Island, Syracuse, and some more usual destinations. Coal trains are identified by various spellings and misspellings of "coal." Many symbols may have never been used for a real train (particularly for Amtrak trains), but they do follow a logical pattern. The symbol for each train is chosen randomly from a list of ten symbols for each possible combination of speed and direction of the train.
The character positions
The 4 character positions are arranged in a square. Left to right, top row to bottom row, these symbols mean the following.
The first number represents how long in minutes the train normally takes to travel through a block before it tries to advance to the next block. There are 4 possible numbers, including 6 for Amtrak trains, 7 and 8 for van, stack, and ML trains, and 9 for coal and mixed trains. This number is chosen randomly from the four possibilities.
The second number represents how much longer the train will be in the current block before attempting to advance. This number is decremented each minute the train remains in the block. When the number reaches 0, the train attempts to advance to the next block on the next click of "Advance Trains." The number continues to be decremented if the train is being held, going negative after the number has reached 0. If the train is not being held but can't advance to the next block because trains are in the next block on both tracks, the number stays the same once it has reached or gone below 0.
The third position represents the direction the train is going. "w" represents westbound trains, "e" represents eastbound trains. This is selected randomly.
The fourth number represents how many minutes the train may be delayed before you are penalized for the delay. This number is decremented when the second number has reached 0 and the train can't or isn't allowed to advance to the next block. When this number goes below 0, the absolute (positive) value of the number represents how many minutes you will be penalized once the train leaves the district. This number is determined based on the priority of the train as defined by its speed, that is, faster trains have smaller numbers, or less make-up time, because they are typically higher priority trains.
Block Colors
When a block turns green, yellow, or red, it indicates what is going on with the train in that block. Green means the train is ready to move to the next block and there has been no delays. Yellow indicates the train is asking to cross over. Red indicates the train is ready to move to the next block but cannot, either because the train is being held, or the next block has a train in it. The "Next Train" block also uses colors meaning the same thing for green or red, but yellow simply warns you that the train must move or it will begin acruing delay minutes immediately.
The information fields
The fields to the right of the track display provide important information as follows.
Next Train Displays the information for the next train that wants to enter. See above for details on the radio buttons and "Hold" button associated with this box.
Time The number in this field represents the number of elapsed minutes since the beginning of the game.
Total Delay Minutes The number in this field represents the total number of minutes past the allowed amount that all trains have been delayed since the start of the game. Every time a train exits the display with a negative number in the lower right corner of that train's displayed information, the absolute (positive) value of that negative number gets added to the Total Delay Minutes field.
Trains Waiting When a new train is generated and can't enter the end of the division it needs to based on the direction it is going, the Trains Waiting field will be incremented. If the Trains Waiting field is greater than 0, the game will generate a train and attempt to place it at the appropriate end of the display. If this attempt succeeds, the Trains Waiting field is decremented by 1, unless another train is generated in that same minute.
Number of trains in This field represents the number of trains that have entered the display.
Number of trains out This field represents the number of trains that have exited the display.
Train Frequency per hour: This menu lets you set the approximate average number of trains generated per 60 minutes of game time. The maximum setting is 15, as the railroad becomes saturated at this frequency. If this is set to 0, an alert will be displayed if there are no trains in the display area.
Show Stats Clicking this button will show a list of how many of each type of train has entered, exited, and their delay statistics, as well as a summary for all trains.
Show History Will show a list of all trains that have been generated with their starting information. This can be saved (by manually copying and pasting the information into a text file you maintain yourself) so the same scenario can be replayed another time. Simply copy a saved list of trains into the "Next Train" box before beginning the next round, then click "Start Game" to play a saved scenario.
Playing the game
I usually play the game for a simulated 24 hours worth of minutes, or 1440 minutes. This usually takes about an hour and a half to 2 hours of real time. You can play the game for as long as you like. There is no theoretical upper limit to the number of minutes except the maximum integer that your computer can store. I'm sure you'll tire of the game long before the computer exhausts its memory, even if you play the game continuously for the rest of your life! You can adjust the average frequency of trains per hour by changing the "Train Frequency per hour" popup menu. If you're overwelmed with trains, choose a lower number and resume play. The game defaults to 4 trains per hour. With this frequency, I typically accumulate between 0 and 60 minutes worth of delays in one round of 1440 minutes of scale time, and often less than 30 minutes of delays. The maximum frequency setting is 15. I have tried the game with this frequency, and the railroad becomes saturated at this point, with an ever increasing number of trains waiting to enter as indicated in the "Trains Waiting" field.
Program History
I originally wrote this game in another language (Hypercard), starting sometime around 1997 or so. I converted it to JavaScript to teach myself JavaScript, and because since I found myself addicted to the game, I figured others would probably be at least somewhat interested in it as well. Since JavaScript is a web based language, the game would be accessible to many more people. This program first appeared on the web in the spring of 2000.
JavaScript Madness
As I wrote the game in JavaScript and the supporting HTML, I came across several problems. While the game is fully functional (save undetected bugs), the layout is not to my satisfaction. In some browsers, (especially old browsers pre Mac OS X systems) I feel there is too much space between the blocks and I would like to get rid of the scroll bars attached to each block. These two things will make the display take up considerably less space. Also, the dialog boxes that ask about crossing or holding or allowing trains to proceed are too big as well as a bit clumsy. Finally, the entire display blinks with every click of a button. If you know how to solve these problems, please let me know. It appears as though all of these problems are fixed in modern browsers.
"Freeware"
You may use this game freely, and use the JavaScript code as sample code for your own programs. Any resemblance of this game to any other game is coincidental, though I am aware of several far more polished train dispatching game software packages. My only request is that you don't take a copy of this code and clam you wrote the game yourself.
"Feedback Ware"
While this game is essentially free, I would be encouraged by any feedback, including suggestions for improvement, bug reports, comments, unusual dispatching situations, questions, etc. Please send such correspondence to me at Bill222E@ensingers.com.
"Shareware"
Though you may use this game freely, there's nothing to stop you from treating it like shareware. If you'd like to send me something for this game, please contact me at Bill222E@ensingers.com.
"Hire-me Ware"
Since I converted this game to JavaScript to teach myself JavaScript, I now know how JavaScript works. If you have an idea that you would like implemented in JavaScript and would like me to program it for you, please contact me at Bill222E@ensingers.com.
Thanks. Enjoy the game!