Ejemplo n.º 1
0
        //the next state for specific cell is computed with specific neighborhood.
        private int ComputeNextStateForOneCell(CellM cellModelIn, int xIn, int yIn)
        {
            ICARuleData aCARuleData = myCARule.CARuleData;
            IList <NeighborhoodAreaItem> aNeighorboodArrayStates = CANeighborhood.GetNeighborhood(myCell2DArray, xIn, yIn, aCARuleData.CANeighborhoodType, aCARuleData.CANeighborhoodRange);

            return(myCARule.ComputeCellState(aNeighorboodArrayStates, cellModelIn.CurrentCellState));
        }
Ejemplo n.º 2
0
        public void CreateAndInitializeCells(ref CellM[,] cellsMIn, int countOfStatesIn)
        {
            Random aRandom = new Random();

            int aFromRow    = (int)((double)cellsMIn.GetLength(1) / 2.0);
            int aUpToColumn = (int)((double)cellsMIn.GetLength(0) / 2.0);

            //going through all cells and setting the appropriate value.
            for (int column = 0; column < cellsMIn.GetLength(0); column++)
            {
                for (int row = 0; row < cellsMIn.GetLength(1); row++)
                {
                    int aRandomNumber = 0;

                    if (row >= aFromRow && column < aUpToColumn)
                    {
                        aRandomNumber = aRandom.Next(0, 2);
                    }

                    if (aRandomNumber == 1)
                    {
                        aRandomNumber = countOfStatesIn - 1;
                    }

                    var aCellModel = new CellM(aRandomNumber, column, row, countOfStatesIn);

                    cellsMIn[column, row] = aCellModel;
                }
            }
        }
Ejemplo n.º 3
0
        public void CreateAndInitializeCells(ref CellM[,] cellsMIn, int countOfStatesIn)
        {
            //going through all cells and setting the appropriate value.
            for (int column = 0; column < cellsMIn.GetLength(0); column++)
            {
                for (int row = 0; row < cellsMIn.GetLength(1); row++)
                {
                    var aCellModel = new CellM(0, column, row, countOfStatesIn);

                    cellsMIn[column, row] = aCellModel;
                }
            }
        }
Ejemplo n.º 4
0
        public CellVM(CellM cellModelIn, int xIn, int yIn)
        {
            X = xIn;
            Y = yIn;

            myCellModel = cellModelIn;

            myNewPossibleCellState = Constants.BaseCellStateForAllAvailableCAs;

            myCellModel.CurrentCellStateChanged += ChangeFillColor;
            myCellModel.CurrentCellStateChanged += NotifyAboutStateChanged;

            CellStateChangedCommand = new RelayCommand(new Action <object>(CellStateChanged));
        }
Ejemplo n.º 5
0
        public CAGrid2DM(int columnsIn, int rowsIn, ICARuleFamily caRuleIn, ICAGridCellInitialization caGridCellInitializationIn)
        {
            myCell2DArray = new CellM[columnsIn, rowsIn];

            myCARule = caRuleIn;

            if (caRuleIn != null && caGridCellInitializationIn != null)
            {
                caGridCellInitializationIn.CreateAndInitializeCells(ref myCell2DArray, myCARule.NumberOfStates);
            }

            MaximumIteration = 0;
            CurrentIteration = 0;
        }