/// <summary> /// Run one generation of the automata on the grid. /// </summary> /// <param name="rule">The 'neighbor skipping rule' to apply</param> public void RunAutomata(AutomataRule rule, bool randomize) { // Empty multi-cast delegate Action automataAction = () => { }; // Add the OrthogonalRule automata for any rule that requires it if(Utility.EnumIsAnyOf<AutomataRule>(rule, AutomataRule.Alternating, AutomataRule.Orthogonal, AutomataRule.CustomRule)) automataAction += () => RunAutomata(Cell.OrthogonalRule, randomize); // Add the DiagonalRule automata for any rule that requires it if (Utility.EnumIsAnyOf<AutomataRule>(rule, AutomataRule.Alternating, AutomataRule.Diagonal)) automataAction += () => RunAutomata(Cell.DiagonalRule, randomize); // Add the CustomRule automata if required if(rule == AutomataRule.CustomRule) automataAction += () => RunAutomata(Cell.CustomRule, randomize); // Run automataAction(); }
public CellularAutomataGenerator(AutomataRule rule, int fulfillment) { this.rule = rule; this.fulfillment = fulfillment; }