if(next_entry_ep.has_path(i))
{
next.trains[train_index].path = i;
- new_steps.push_back(next);
+ if(next.is_viable())
+ new_steps.push_back(next);
}
if(next_entry_ep.paths!=next_track->get_type().get_paths())
RoutingStep wait(&step);
wait.advance(dt);
wait.trains[train_index].state = WAITING;
- new_steps.push_back(wait);
+ if(wait.is_viable())
+ new_steps.push_back(wait);
}
}
}
}
+bool TrainRoutePlanner::RoutingStep::is_viable() const
+{
+ for(vector<TrainRoutingState>::const_iterator i=trains.begin(); i!=trains.end(); ++i)
+ if(i->state==MOVING)
+ return true;
+
+ return false;
+}
+
bool TrainRoutePlanner::RoutingStep::is_goal() const
{
for(vector<TrainRoutingState>::const_iterator i=trains.begin(); i!=trains.end(); ++i)
RoutingStep(RoutingStep *);
void advance(const Msp::Time::TimeDelta &);
+ bool is_viable() const;
bool is_goal() const;
bool operator<(const RoutingStep &) const;