Configurations properties


If you want to build your own cellular automata configuration (CellularAutomataConfiguration), you must use the CellularAutomataConfigurationBuilder.

The following example shows you how to build a configuration.

Please remember that creating an instance of CellularAutomataConfiguration is mandatory in order to create an instance of CellularAutomata.

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();

On this page, I will show you all the possible configuration options that you can use.

Width

Set the matrix width (the number of columns).

Default is 100

Here is the signature of the method:

public CellularAutomataConfigurationBuilder setWidth(int width);

Height

Set the matrix height (the number of rows)

Default is 100

Here is the signature of the method:

public CellularAutomataConfigurationBuilder setHeight(int height);

Infinite Loop

If you want to loop infinitely, simply set the following configuration to true.

Default is false

Here is the signature of the method:

public CellularAutomataConfigurationBuilder setInfinite(boolean isInfinite);

Total interactions

Set the number of iterations of the transition function

This parameter is mandatory if isInfinite is not setted.

Here is the signature of the method:

public CellularAutomataConfigurationBuilder setTotalIterations(int totalIterations);

Default status

Set the default status for each cell of the CA’s map.

This parameter is mandatory.

Here is the signature of the method:

public CellularAutomataConfigurationBuilder setDefaultStatus(DefaultStatus defaultStatus);

Initial condition

Set the initial configuration from where to start the cellular automata. In other words, set the cells that have a different status than empty/dead in the starting phase.

Here is the signature of the method:

public CellularAutomataConfigurationBuilder setInitalState(List<DefaultCell> initalState);

Default Neighborhood

If you don’t have a custom neighborhood you can choose one already implemented in the NeighborhoodType enum.

Here is the signature of the method:

public CellularAutomataConfigurationBuilder setNeighborhoodType(NeighborhoodType neighborhoodType);

Custom Neighborhood

If you have a custom neighborhood, you can set your class here.

The class has to inerhit the DefaultNeighborhood class.

Here is the signature of the method:

public CellularAutomataConfigurationBuilder setNeighborhood(DefaultNeighborhood neighborhood);