public void TestLangtonIterate()
        {
            bool[,] StartingContent = new bool[8, 8]
            {
                { false, false, false, false, false, false, false, false },
                { false, false, false, false, false, false, false, false },
                { false, false, false, false, false, false, false, false },
                { false, false, false, false, false, false, false, false },
                { true, false, false, false, false, false, false, false },
                { false, false, false, false, false, false, false, false },
                { false, false, false, false, false, false, false, false },
                { false, false, false, false, false, false, false, false }
            };

            CircularArray2D <bool>         StartingArray     = new CircularArray2D <bool>(StartingContent);
            CellularAutomata <LangtonsAnt> _CellularAutomata = new CellularAutomata <LangtonsAnt>(StartingArray);

            bool[,] IteratedContent = _CellularAutomata.Iterate();

            bool[,] ModelContent = new bool[8, 8]
            {
                { false, false, false, false, true, false, false, false },
                { false, false, false, false, false, false, false, false },
                { false, true, false, false, false, true, false, false },
                { false, false, false, false, false, false, false, false },
                { false, false, true, false, false, false, true, false },
                { false, false, false, false, false, false, false, false },
                { false, false, false, true, false, false, false, true },
                { false, false, false, false, false, false, false, false }
            };

            Assert.AreEqual(IteratedContent, ModelContent);
        }
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();

        CellularAutomata Automata = (CellularAutomata)target;

        if (GUILayout.Button("Generate Room"))
        {
            Automata.GenerateRoom();
        }

        GUILayout.BeginHorizontal();
        if (GUILayout.Button("Restart"))
        {
            Automata.FillRandom();
            Automata.DrawRoom();
        }
        if (GUILayout.Button("Iterate"))
        {
            Automata.Iterate();
        }
        if (GUILayout.Button("Change States"))
        {
            Automata.ChangeStates();
            Automata.DrawRoom();
        }
        GUILayout.EndHorizontal();
    }
Example #3
0
        /// <summary>
        /// calculate chord progression
        /// </summary>
        public void CalculateChordProgression()
        {
            //prepare chord progression
            if (chordProgressionGenerator == null)
            {
                chordProgressionGenerator        = new CellularAutomata <Rule30>(new CircularArray2D <bool>(CellValues[Numbers.Zero]));
                chordProgressionGenerator.Repeat = Numbers.One;
            }

            string s = "Chord Progression: ";

            ChordProgression = new int[_CellularAutomata[Numbers.Zero].Repeat];

            for (int z = 0; z < _CellularAutomata[Numbers.Zero].Repeat; z++)
            {
                for (int x = 0; x < _CellularAutomata[Numbers.Zero].Repeat; x++)
                {
                    for (int y = 0; y < Numbers.Twelve; y++)
                    {
                        if (chordProgressionGenerator[x, y])
                        {
                            ChordProgression[z] = ChordProgression[z] + y + (x * 10);
                        }
                    }
                }
                chordProgressionGenerator.Iterate();

                ChordProgression[z] %= Numbers.TwentyFour;

                ChordProgression[z] -= Numbers.Twelve;

                s += ChordProgression[z] + " ";
            }

            Console.WriteLine(s);
        }