Controller - Deadlock prevention 

Page / - last modified by stu114053 on 2025/01/30 12:17 

Deadlock prevention 
last modified by stu114053
on 2025/01/30 12:17

Table of Contents
Inputs:
Features:

Inputs:
•	position and train_on_track
•	pre_next_segment
•	moving
•	track_speeds
Features:
•	Take an alternative route (route == 1): on full station (KH, KH_REV, IC, OC) or other special for deadlocks prevention
•	e.g. if KH_ST is full and the KIO_LN are occupied by incoming (into KH) trains a train leaving KH should always leave through KH
•	Lock the entrance to KH_LN and KH_LN_REV and the corresponding exit of the turnout track: more than two trains travel in the opposite direction of KH
•	Assign a random destination to trains: that are in a station, have no destination and are blocking other trains
•	random_destination is calculated deterministically
•	can be disabled for each train by setting no_forced_direction
•	KH_ST is full in one direction and the KIO_LN in the opposite direction/ exit of the turnout track are locked: depends on how busy KH_LN is and if someone wants to enter from KH_LN (same for REV)
•	Lock opposite direction in KH: a train in the KH pass may have to wait for a long time if trains are looping in the opposite direction, so wait for two trains (waiting_bound_KH in KH_Deadlock_Prevention) and then enable its movement
•	Set a random destination for each train (random_mode == true): sets destination if train doesn't have one