From: Mikko Rasa Date: Mon, 23 Mar 2015 21:12:33 +0000 (+0200) Subject: Tweak the picking of the next train to process X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=28947c087bd2d05c1850e320844f2e33fc0fc253;p=r2c2.git Tweak the picking of the next train to process If a train just became unblocked, it should be considered for picking immediately. --- diff --git a/source/libr2c2/trainrouteplanner.cpp b/source/libr2c2/trainrouteplanner.cpp index 95b981c..c07f9e8 100644 --- a/source/libr2c2/trainrouteplanner.cpp +++ b/source/libr2c2/trainrouteplanner.cpp @@ -569,7 +569,7 @@ void TrainRoutePlanner::RoutingStep::create_successors(list &new_st if(next.update_states() && next.check_deadlocks()) return; - int train_index = find_next_train(); + int train_index = next.find_next_train(); if(train_index<0) return; @@ -726,10 +726,13 @@ int TrainRoutePlanner::RoutingStep::get_occupant(Track &track) const int TrainRoutePlanner::RoutingStep::find_next_train() const { + /* Pick a moving train with the lowest time to next track. A train that + just became blocked can still travel until the end of its current track, + so consider those too. */ Time::TimeDelta min_dt; int next_train = -1; for(unsigned i=0; itrains[i].state==MOVING)) { Time::TimeDelta dt = trains[i].get_time_to_next_track(); if(dt