示例#1
0
        public CellularAutomaton(int width, int height, Ruleset ruleset, float startNoise, bool aliveBorders)
        {
            this.width = width;
            this.height = height;
            this.ruleset = ruleset;
            this.aliveBorders = aliveBorders;
            cells = new CellState[width, height];
            copy = new CellState[width, height];

            visitAliveBorders = (int neighbourX, int neighbourY) =>
            {
                if (copy.IsInBounds(neighbourX, neighbourY))
                {
                    if (copy[neighbourX, neighbourY] == CellState.Alive)
                    {
                        aliveNeighbours++;
                    }
                }
                else
                {
                    aliveNeighbours++;
                }
            };
            visitDeadBorders = (int neighbourX, int neighbourY) =>
            {
                if (copy[neighbourX, neighbourY] == CellState.Alive)
                {
                    aliveNeighbours++;
                }
            };

            FillWithNoise(startNoise);
        }
示例#2
0
        private void SelectRuleset(RulesetName rulesetName)
        {
            ruleset = nameToRuleset[rulesetName];

            header.Initialize("Rulestring: " + ruleset);
        }