Package itumulator.simulator
Class Simulator
java.lang.Object
itumulator.simulator.Simulator
Simulator handles the execution of actual simulations and keeps track of how many steps have been executed (Not required to execute and build simulations).
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintgetDelay()Provides the current delayintgetSteps()Provides the amount of iteration steps executedbooleanProvides a status of whetherrunis currently being executed.voidrun()Executes simulation steps in a parallel process.voidsetDelay(int delay) Updates the delay to be used.voidSets the containing frame to allow updating of meta world information (day/night cycle).voidsimulate()Simulate am iteration.voidstop()Stops an execution ofrun.
-
Constructor Details
-
Simulator
Initializes a new simulation based on an existing world, canvas, and initial delay.- Parameters:
world- the world to simulate.canvas- the canvas to use for simulation.delay- between executing simulations in ms (when usingrun).
-
-
Method Details
-
setFrame
Sets the containing frame to allow updating of meta world information (day/night cycle).- Parameters:
frame- to use.
-
getSteps
public int getSteps()Provides the amount of iteration steps executed- Returns:
- steps executed.
-
getDelay
public int getDelay()Provides the current delay- Returns:
- the delay currently employed.
-
simulate
public void simulate()Simulate am iteration. -
isRunning
public boolean isRunning()Provides a status of whetherrunis currently being executed.- Returns:
- true if
runis currently in progress.
-
setDelay
public void setDelay(int delay) Updates the delay to be used.- Parameters:
delay- to use in ms.- Throws:
IllegalArgumentException- if delay is negative.IllegalStateException- if modifying delay while runningrun.
-
stop
public void stop()Stops an execution ofrun.- Throws:
IllegalStateException- ifrunis not currently executing.
-
run
public void run()Executes simulation steps in a parallel process. Can be stopped usingstop.
-