diff options
author | orwell96 <orwell@bleipb.de> | 2021-01-02 18:00:12 +0100 |
---|---|---|
committer | orwell96 <orwell@bleipb.de> | 2021-02-10 16:39:46 +0100 |
commit | 8f4c90c5a53b531451436b8e0a1ea8a3b750110e (patch) | |
tree | a347eddc1ec522eb083430417f79c129cde2ddfc /advtrains/lzb.lua | |
parent | 3c42d87dc0b4b3aed454e68541bff711dba75dc9 (diff) | |
download | advtrains-8f4c90c5a53b531451436b8e0a1ea8a3b750110e.tar.gz advtrains-8f4c90c5a53b531451436b8e0a1ea8a3b750110e.tar.bz2 advtrains-8f4c90c5a53b531451436b8e0a1ea8a3b750110e.zip |
Add debug prints, modify LZB to fix problems with look_ahead
Diffstat (limited to 'advtrains/lzb.lua')
-rw-r--r-- | advtrains/lzb.lua | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/advtrains/lzb.lua b/advtrains/lzb.lua index a5e361c..1aa9e5f 100644 --- a/advtrains/lzb.lua +++ b/advtrains/lzb.lua @@ -77,10 +77,15 @@ end local function look_ahead(id, train) local acc = advtrains.get_acceleration(train, 1) - local vel = train.velocity + -- worst-case: the starting point is maximum speed + local vel = train.max_speed or train.velocity local brakedst = ( -(vel*vel) / (2*acc) ) * params.DST_FACTOR - local brake_i = advtrains.path_get_index_by_offset(train, train.index, brakedst + params.BRAKE_SPACE) + --local brake_i = advtrains.path_get_index_by_offset(train, train.index, brakedst + params.BRAKE_SPACE) + -- worst case (don't use index_by_offset) + brake_i = atfloor(train.index + brakedst + params.BRAKE_SPACE) + atprint("LZB: looking ahead up to ", brake_i) + --local aware_i = advtrains.path_get_index_by_offset(train, brake_i, AWARE_ZONE) local lzb = train.lzb @@ -122,6 +127,7 @@ local function call_runover_callbacks(id, train) local ckp = train.lzb.checkpoints while ckp[i] do if ckp[i].index <= idx then + atprint("LZB: checkpoint run over: i=",ckp[i].index,"s=",ckp[i].speed) -- call callback local it = ckp[i] if it.callback then @@ -140,6 +146,7 @@ local function apply_checkpoint_to_path(train, checkpoint) if not checkpoint.speed then return end + atprint("LZB: applying checkpoint: i=",checkpoint.index,"s=",checkpoint.speed) -- make sure path exists until checkpoint local pos = advtrains.path_get(train, checkpoint.index) |