Esempio n. 1
0
        public void SetAllEdges(CellCornerState SetState)
        {
            int Ctr;

            for (Ctr = 0; Ctr < cCellVertexes.Count; Ctr++)
            {
                cCellVertexes[Ctr][0] = SetState;
                cCellVertexes[Ctr][(int)cColCount] = SetState;
            }

            for (Ctr = 0; Ctr <= cColCount; Ctr++)
            {
                cCellVertexes[0][Ctr] = SetState;
                cCellVertexes[(int)cRowCount][Ctr] = SetState;
            }
        }
Esempio n. 2
0
        public void CellularAutomatonPass(CellCornerState GridEdge, int BirthLimit, int NeighborMinLmit, int NeighborMaxLimit)
        {
            int ColCtr, RowCtr, NeighborCount;
            List <List <CellCornerState> > NewVertexList = new List <List <CellCornerState> >();
            List <CellCornerState>         NewRow;

            for (RowCtr = 0; RowCtr < cCellVertexes.Count; RowCtr++)
            {
                NewRow = new List <CellCornerState>();
                NewVertexList.Add(NewRow);

                for (ColCtr = 0; ColCtr < cCellVertexes[RowCtr].Count; ColCtr++)
                {
                    NeighborCount = GetCellSolidNeighborCount(RowCtr, ColCtr, GridEdge);

                    if (cCellVertexes[RowCtr][ColCtr] == CellCornerState.Solid)
                    {
                        if ((NeighborCount < NeighborMinLmit) || (NeighborCount > NeighborMaxLimit))
                        {
                            NewRow.Add(CellCornerState.Empty);
                        }
                        else
                        {
                            NewRow.Add(CellCornerState.Solid);
                        }
                    }
                    else
                    {
                        if (NeighborCount > BirthLimit)
                        {
                            NewRow.Add(CellCornerState.Solid);
                        }
                        else
                        {
                            NewRow.Add(CellCornerState.Empty);
                        }
                    }
                }
            }

            cCellVertexes = NewVertexList;
            HasChanged    = true;
        }
Esempio n. 3
0
        private int GetCellSolidNeighborCount(int Row, int Col, CellCornerState GridEdge)
        {
            List <CellCornerState> Neighbors = new List <CellCornerState>();
            int ColCtr, RowCtr;

            //Generate a list of neighbors
            for (ColCtr = -1; ColCtr < 2; ColCtr++)
            {
                for (RowCtr = -1; RowCtr < 2; RowCtr++)
                {
                    if ((ColCtr == 0) && (RowCtr == 0))
                    {
                        continue;                         //Skip the center, we only want neighbors
                    }

                    if ((Row + RowCtr < 0) || (Row + RowCtr > RowCount) || (Col + ColCtr < 0) || (Col + ColCtr > ColumnCount))
                    {
                        //Neighbor is outside the grid
                        Neighbors.Add(GridEdge);
                    }
                    else
                    {
                        Neighbors.Add(cCellVertexes[Row + RowCtr][Col + ColCtr]);
                    }
                }
            }

            //Count the solid neighbors
            ColCtr = 0;
            foreach (CellCornerState CurrVal in Neighbors)
            {
                if (CurrVal == CellCornerState.Solid)
                {
                    ColCtr++;
                }
            }

            return(ColCtr);
        }
Esempio n. 4
0
		private int GetCellSolidNeighborCount(int Row, int Col, CellCornerState GridEdge) {
			List<CellCornerState> Neighbors = new List<CellCornerState>();
			int ColCtr, RowCtr;

			//Generate a list of neighbors
			for (ColCtr = -1; ColCtr < 2; ColCtr++) {
				for (RowCtr = -1; RowCtr < 2; RowCtr++) {
					if ((ColCtr == 0) && (RowCtr == 0)) {
						continue; //Skip the center, we only want neighbors
					}

					if ((Row + RowCtr < 0) || (Row + RowCtr > RowCount) || (Col + ColCtr < 0) || (Col + ColCtr > ColumnCount)) {
						//Neighbor is outside the grid
						Neighbors.Add(GridEdge);
					} else {
						Neighbors.Add(cCellVertexes[Row + RowCtr][Col + ColCtr]);
					}
				}
			}

			//Count the solid neighbors
			ColCtr = 0;
			foreach (CellCornerState CurrVal in Neighbors) {
				if (CurrVal == CellCornerState.Solid) {
					ColCtr++;
				}
			}

			return ColCtr;
		}
Esempio n. 5
0
		public void SetAllEdges(CellCornerState SetState) {
			int Ctr;

			for (Ctr = 0; Ctr < cCellVertexes.Count; Ctr++) {
				cCellVertexes[Ctr][0] = SetState;
				cCellVertexes[Ctr][(int)cColCount] = SetState;
			}

			for (Ctr = 0; Ctr <= cColCount; Ctr++) {
				cCellVertexes[0][Ctr] = SetState;
				cCellVertexes[(int)cRowCount][Ctr] = SetState;
			}
		}
Esempio n. 6
0
		public void CellularAutomatonPass(CellCornerState GridEdge, int BirthLimit, int NeighborMinLmit, int NeighborMaxLimit) {
			int ColCtr, RowCtr, NeighborCount;
			List<List<CellCornerState>> NewVertexList = new List<List<CellCornerState>>();
			List<CellCornerState> NewRow;

			for (RowCtr = 0; RowCtr < cCellVertexes.Count; RowCtr++) {
				NewRow = new List<CellCornerState>();
				NewVertexList.Add(NewRow);

				for (ColCtr = 0; ColCtr < cCellVertexes[RowCtr].Count; ColCtr++) {
					NeighborCount = GetCellSolidNeighborCount(RowCtr, ColCtr, GridEdge);

					if (cCellVertexes[RowCtr][ColCtr] == CellCornerState.Solid) {
						if ((NeighborCount < NeighborMinLmit) || (NeighborCount > NeighborMaxLimit)) {
							NewRow.Add(CellCornerState.Empty);
						} else {
							NewRow.Add(CellCornerState.Solid);
						}
					} else {
						if (NeighborCount > BirthLimit) {
							NewRow.Add(CellCornerState.Solid);
						} else {
							NewRow.Add(CellCornerState.Empty);
						}
					}
				}
			}

			cCellVertexes = NewVertexList;
			HasChanged = true;
		}
Esempio n. 7
0
		public void SetCellCornerState(int CornerRow, int CornerColumn, CellCornerState State) {
			cCellVertexes[CornerRow][CornerColumn] = State;
			HasChanged = true;
		}
Esempio n. 8
0
 public void SetCellCornerState(int CornerRow, int CornerColumn, CellCornerState State)
 {
     cCellVertexes[CornerRow][CornerColumn] = State;
     HasChanged = true;
 }