function f = terminal_state(world_state, P)

% basic check on final time
if world_state.car_states(1).t > P.time_final - eps
  f = true;
  return
end

% check if past desired final state
final_states = [P.cars.goal_state];

% check on final states
f = sum([world_state.car_states.x] > [final_states.x]) == length(P.cars);
