Esempio n. 1
0
 public CA1D()
 {
     InitializeComponent();
     this.RectWidth = 5;
     this.RowSize = 50;
     this.Layers = new List<Layer>();
     this.DataContext = this;
     this.RandomConfig = true;
     for (int i = 0; i < 1; i++) {
         this.Layers.Add(Layer.Generate(NUMBER_OF_STATES, RowSize, j => rand.Next(5)));
     }
     system = new CASystem(NUMBER_OF_STATES, this.Layers.First(), transitionRule);
     this.LayersControl.ItemsSource = this.Layers;
     this.iterate_bw = new BackgroundWorker();
     this.iterate_bw.DoWork += new DoWorkEventHandler(iterate_bw_DoWork);
 }
Esempio n. 2
0
        private void restart()
        {
            this.Layers.Clear();
            if (this.RandomConfig) {
                this.Layers.Add(Layer.Generate(NUMBER_OF_STATES, RowSize, i => rand.Next(5)));
            } else {
                this.Layers.Add(Layer.Generate(NUMBER_OF_STATES, RowSize, i => {
                    if (RowSize / 2 == i) {
                        return 0;
                    } else {
                        return 1;
                    }
                }));
            }

            system = new CASystem(NUMBER_OF_STATES, this.Layers.First(), transitionRule);
            updateLayersUI();
        }