Configuration Reference

To run a cellular automaton with JCAL, you must first build a CellularAutomataConfiguration using the fluent CellularAutomataConfigurationBuilder. Configuration objects are immutable once built; all settings must be applied before calling .build().

CellularAutomataConfigurationBuilder configBuilder = new CellularAutomataConfigurationBuilder();
CellularAutomataConfiguration config = configBuilder.setHeight(50)
                                                    .setWidth(50)
                                                    .setTotalIterations(10)
                                                    .setStatusList(/* a List */)
                                                    .setNeighborhoodType(NeighborhoodType.MOORE)
                                                    .setDefaultStatus(new DefaultStatus("key", "value"))
                                                    /** ... */
                                                    .build();

Width

Sets the number of columns in the grid.

Default: 100

Parameter Type
width int
public CellularAutomataConfigurationBuilder setWidth(int width);

Height

Sets the number of rows in the grid.

Default: 100

Parameter Type
height int
public CellularAutomataConfigurationBuilder setHeight(int height);

Infinite loop

When set to true, the automaton runs indefinitely until interrupted. When false (the default), the automaton stops after totalIterations steps.

Default: false

Note: setInfinite(true) and setTotalIterations are mutually exclusive.

Parameter Type
isInfinite boolean
public CellularAutomataConfigurationBuilder setInfinite(boolean isInfinite);

Total iterations

Sets the number of generations (steps) to simulate.

Required when isInfinite is false.

Parameter Type
totalIterations int
public CellularAutomataConfigurationBuilder setTotalIterations(int totalIterations);

Default status

Sets the initial state applied to every cell in the grid before the initial condition is overlaid. This is typically the “empty” or “dead” state.

Required.

Parameter Type
defaultStatus DefaultStatus
public CellularAutomataConfigurationBuilder setDefaultStatus(DefaultStatus defaultStatus);

Initial condition

Provides the list of cells that start in a state other than the default. All other cells are initialized with the default status.

Parameter Type
initalState List<DefaultCell>
public CellularAutomataConfigurationBuilder setInitalState(List<DefaultCell> initalState);

Built-in neighborhood

Selects one of the pre-defined neighborhood shapes from the NeighborhoodType enum.

Parameter Type Values
neighborhoodType NeighborhoodType MOORE, VON_NEUMANN
public CellularAutomataConfigurationBuilder setNeighborhoodType(NeighborhoodType neighborhoodType);

Custom neighborhood

Provides a custom neighborhood implementation. The class must extend DefaultNeighborhood.

Note: Use either setNeighborhoodType or setNeighborhood — not both.

Parameter Type
neighborhood DefaultNeighborhood
public CellularAutomataConfigurationBuilder setNeighborhood(DefaultNeighborhood neighborhood);

See also