🚦 Train Dispatch Queue Lab

Who's next? Run a first-in, first-out queue and discover how a small delay changes everyone's waiting time.

A toy model, not railway operating advice. One dispatcher, one queue, two-minute departure slots. Arrivals happen at the stated minute, including while a slot is busy. Ties follow the timetable's letter order. Travel time, signals, priorities and safety rules are outside this model.

1. Choose a timetable

Minute 0

2. Watch the queue

New arrivals join the back. Dispatch removes only the front train. The numbers below show position, not priority.

    No trains waiting.

    Departure log

    3. Three dispatcher missions

    1. Morning mix: dispatch whenever a train is waiting. Predict which train comes next before every click. What total waiting time do you get?
    2. Reset Morning mix. Wait one minute before your first dispatch, then dispatch all four. Compare totals. Why can one minute of hesitation create more than one train-minute of extra waiting?
    3. Spaced arrivals: advance time only when the queue is empty. Can every train have zero waiting time? Then try Rush and explain why some waiting is unavoidable.

    The maths behind the log

    Waiting time = departure minute − arrival minute. A train arriving during another departure slot joins the back and waits until that slot ends. Average waiting = total waiting ÷ number of departed trains; the display rounds the average to one decimal place. “Train-minutes” adds waiting across trains, not the elapsed clock time.

    Queue versus stack

    This queue uses FIFO: first in, first out. Adding at the back is enqueue; removing from the front is dequeue. In the Shunting Stack Lab, the last wagon pushed is the first popped: LIFO. Neither rule is a complete model of real railway dispatching.

    4. Check your reasoning

    Keep exploring

    Compare a stack · Sort wagon numbers · All courses

    No account, saved scores, browser storage or input uploads. Reloading resets the experiment.