Record Class SimulationOptions

java.lang.Object
java.lang.Record
dev.twilite.game.simulation.model.SimulationOptions
Record Components:
width - number of columns in the simulated grid
height - number of rows in the simulated grid
maxTicks - maximum number of movement ticks to expand
diagonals - whether diagonal movement is allowed
moveSpeed - movement rate used during expansion

public record SimulationOptions(int width, int height, int maxTicks, boolean diagonals, MoveSpeed moveSpeed) extends Record
Static bounds and movement settings for a simulation run.
  • Constructor Details

    • SimulationOptions

      public SimulationOptions(int width, int height, int maxTicks, boolean diagonals, MoveSpeed moveSpeed)
      Creates an instance of a SimulationOptions record class.
      Parameters:
      width - the value for the width record component
      height - the value for the height record component
      maxTicks - the value for the maxTicks record component
      diagonals - the value for the diagonals record component
      moveSpeed - the value for the moveSpeed record component
  • Method Details

    • grid

      public static SimulationOptions grid(int width, int height)
      Creates default options for a bounded grid.

      Defaults to diagonal movement enabled, walking movement, and width * height expansion ticks.

      Parameters:
      width - number of columns in the simulated grid
      height - number of rows in the simulated grid
    • maxTicks

      public SimulationOptions maxTicks(int maxTicks)
      Returns a copy with a different maximum expansion depth.
      Parameters:
      maxTicks - maximum number of movement ticks to expand
    • diagonals

      public SimulationOptions diagonals(boolean diagonals)
      Returns a copy with diagonal movement enabled or disabled.
      Parameters:
      diagonals - whether diagonal movement is allowed
    • moveSpeed

      public SimulationOptions moveSpeed(MoveSpeed moveSpeed)
      Returns a copy with a different movement speed.
      Parameters:
      moveSpeed - movement rate to use during expansion
    • contains

      public boolean contains(Coord coord)
      Returns whether a coordinate is inside the configured grid bounds.

      The floor is ignored because simulation bounds are two-dimensional.

      Parameters:
      coord - coordinate to test
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • width

      public int width()
      Returns the value of the width record component.
      Returns:
      the value of the width record component
    • height

      public int height()
      Returns the value of the height record component.
      Returns:
      the value of the height record component
    • maxTicks

      public int maxTicks()
      Returns the value of the maxTicks record component.
      Returns:
      the value of the maxTicks record component
    • diagonals

      public boolean diagonals()
      Returns the value of the diagonals record component.
      Returns:
      the value of the diagonals record component
    • moveSpeed

      public MoveSpeed moveSpeed()
      Returns the value of the moveSpeed record component.
      Returns:
      the value of the moveSpeed record component