/** Resets the simulation to default values. */ public static void reset() { // cannot stop until the current step // and rendering is complete synchronized (ui) { IJunction jn = (IJunction) getOption(JUNCTION_TYPE); jn.removeVehicles(); totalTimeSteps = (int) settings.get(TIME_STEP); setOption(TIME_STEP, 0); started = false; paused = false; ui.clearJunctionCache(); ui.updateGUI(); } }
/** Simulates a single step in the simulation. */ private static void simulateOneStep() { // prevent rendering while AI processes synchronized (Simulation.class) { // core simulation step progress. IJunction junc = (IJunction) getOption(Simulation.JUNCTION_TYPE); // FIXME: fix this when junctions are migrated completely to IJunction int carsRatio = (Integer) getOption(Simulation.CAR_RATIO); int trucksRatio = (Integer) getOption(Simulation.TRUCK_RATIO); junc.distributeNewCars(carsRatio, trucksRatio); junc .manageJunction(); // goes through all lanes contained in the junction, and tells each car // within each lane to "act" junc.updateDeletions(); // when cars go outof the end of the junction, they get "deleted" and statistics are // incremented. setOption(TIME_STEP, ((int) getOption(TIME_STEP) + 1)); } }