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 TypeMethodDescriptionint
getDelay()
Provides the current delayint
getSteps()
Provides the amount of iteration steps executedboolean
Provides a status of whetherrun
is currently being executed.void
run()
Executes simulation steps in a parallel process.void
setDelay
(int delay) Updates the delay to be used.void
Sets the containing frame to allow updating of meta world information (day/night cycle).void
simulate()
Simulate am iteration.void
stop()
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 whetherrun
is currently being executed.- Returns:
- true if
run
is 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
- ifrun
is not currently executing.
-
run
public void run()Executes simulation steps in a parallel process. Can be stopped usingstop
.
-