Dave your Python stuff is interesting, but a lot of it is over my head. (I've never personally tinkered with a Raspberry Pi.)
It's a missed opportunity on Lionel's part that it can't be done solely with LCS components. At least they have been open to sharing the protocols with outside developers such as yourself. I believe that we would have had something like the OP asked about YEARS ago, if MTH hadn't sent heavy-handed "cease and desist" letters to folks who successfully connected their computers to the TIU.
DCS has a couple of advantages relative to TMCC, in that it tracks the distance a loco has traveled, and at least claims to have "two-way communication" coming back from the loco. I have messed around with recording macros/scripts using the TIU and DCS hand-held. They are repeatable to a point, but after multiple cycles, position errors creep in (because of wheel slippage, mismeasurement, etc.) I think you can accomplish this with Legacy/LCS by using the track IR sensors, but it might require some trial-and-error with the commands (or a generous buffer zone) to account for gradual deceleration and stopping distance.
Neither DCS nor Legacy has a built-in provision for randomness: i.e., which loco or route will be selected, how many cycles, duration of delay, etc. These are the kinds of things that would make a display layout interesting to watch and interact with for a human operator. Something to consider IMO.