Class Simulator

java.lang.Object
itumulator.simulator.Simulator

public class Simulator extends Object
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
    Constructor
    Description
    Simulator(World world, Canvas canvas, int delay)
    Initializes a new simulation based on an existing world, canvas, and initial delay.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Provides the current delay
    int
    Provides the amount of iteration steps executed
    boolean
    Provides a status of whether run is currently being executed.
    void
    run()
    Executes simulation steps in a parallel process.
    void
    setDelay(int delay)
    Updates the delay to be used.
    void
    setFrame(Frame frame)
    Sets the containing frame to allow updating of meta world information (day/night cycle).
    void
    Simulate am iteration.
    void
    Stops an execution of run.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Simulator

      public Simulator(World world, Canvas canvas, int delay)
      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 using run).
  • Method Details

    • setFrame

      public void setFrame(Frame frame)
      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 whether run 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 running run.
    • stop

      public void stop()
      Stops an execution of run.
      Throws:
      IllegalStateException - if run is not currently executing.
    • run

      public void run()
      Executes simulation steps in a parallel process. Can be stopped using stop.