Class Sim


public abstract class Sim extends Object
The simulation keeps track of the field and simulation-related things, like the current step.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected Field
     
    protected int
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Sim(int rows, int cols)
    Create a new simulation with a field with the specified dimensions.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    draw(javafx.scene.canvas.GraphicsContext g, int cellsize)
    Draw the current state of the simulation.
    int
    Return the current simulation step number.
    boolean
    Is the simulation over?
    void
    Reset the simulation.
    void
    Advance the simulation one step.

    Methods inherited from class java.lang.Object

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

    • field_

      protected Field field_
    • step_

      protected int step_
  • Constructor Details

    • Sim

      protected Sim(int rows, int cols)
      Create a new simulation with a field with the specified dimensions.
      Parameters:
      rows - rows in the field
      cols - columns in the field
  • Method Details

    • reset

      public void reset()
      Reset the simulation.
    • getStep

      public int getStep()
      Return the current simulation step number.
      Returns:
      current simulation step number
    • step

      public void step()
      Advance the simulation one step. (Does not include repainting.)
    • isOver

      public boolean isOver()
      Is the simulation over?
      Returns:
      true if the simulation is over, false otherwise
    • draw

      public void draw(javafx.scene.canvas.GraphicsContext g, int cellsize)
      Draw the current state of the simulation.
      Parameters:
      g - graphics context
      cellsize - size (in pixels) for one grid cell