Orasund / elm-cellautomata / CellAutomata.New

This module is the new version of the cell automata package.


type alias CellAutomata comparable state =
{ rules : Dict String (List (CellAutomata.Rule.Rule comparable state))
, neighbors : comparable -> List { location : comparable
, direction : comparable }
, groups : Maybe state -> String 
}

This type contains the needed information to compute the next step of an automata.

new : { rules : List (CellAutomata.Rule.Rule comparable state), neighbors : comparable -> List { location : comparable, direction : comparable } } -> CellAutomata comparable state

Construct a new cell automata

step : CellAutomata comparable state -> Dict comparable state -> comparable -> Maybe state -> Maybe state

Compute a step using a cell automata

withGroups : (Maybe state -> String) -> CellAutomata comparable state -> CellAutomata comparable state

If you have a lot of rules, it might be good to group them by initial state. To do so, you have to provide a function that map the states to the names of the groups.