/// <summary> /// /// </summary> private void Update() { _model.Step(); _stepCount++; int[,] state = _model.CurrentState; // update cells based on current state of model for (int y = 0; y < _countY; y++) { for (int x = 0; x < _countX; x++) { _cells[y, x].State = state[y, x]; } // call the function that calculates the density of different frames _layerDensity = CalculateDensity(_countY, _countX); // store the density of different frames in a list _layerDensityList.Add(_layerDensity); // call the function that calculates and stores the age of the cells CalculateCellAges(); } }
/// <summary> /// /// </summary> private void Update() { //float density = CalculateDensity(); //if (density > 0.3) //{ // _model.Step2(); //} //if (density < 0.15) //{ // _model.Step(); //} _model.Step(); _stepCount++; //Debug.Log($"{_stepCount} steps taken!"); int[,] state = _model.CurrentState; for (int y = 0; y < _countY; y++) { for (int x = 0; x < _countX; x++) { if (_cells[y, x].State == 1 && state[y, x] == 1) { _cells[y, x].Age += 1; } else if (_cells[y, x].State == 0 && state[y, x] == 1) { _cells[y, x].Age = 1; } else if (state[y, x] == 0) { _cells[y, x].Age = 0; } if (_cells[y, x].Age >= 50) { _cells[y, x].Age = 0; } // update cells based on current state of model _cells[y, x].State = state[y, x]; _cellList.Add(_cells[y, x]); _frameList.Add(_cellList); } } }
/// <summary> /// /// </summary> private void Update() { _model.Step(); _stepCount++; // Debug.Log($"{_stepCount} steps taken!"); int[,] state = _model.CurrentState; // update cells based on current state of model for (int y = 0; y < _countY; y++) { for (int x = 0; x < _countX; x++) { _cells[y, x].State = state[y, x]; } } }
/// <summary> /// /// </summary> private void Update() { _model.Step(); _stepCount++; // Debug.Log($"{_stepCount} steps taken!"); int[,] state = _model.CurrentState; // update cells based on current state of model for (int y = 0; y < _countY; y++) { for (int x = 0; x < _countX; x++) { _cells[y, x].State = state[y, x]; aliveCellsCount += _cells[y, x].State; _cells[y, x].Age = state[y, x] > 0 ? _cells[y, x].Age + 1 : 0; } } // update cells age Debug.Log($"count: " + aliveCellsCount); aliveCellsCounts.Add(aliveCellsCount); aliveCellsCount = 0; changeColor = DisplayColor(); StartCoroutine(changeColor); if (Time.time > 5) { StopCoroutine(DisplayColor()); StopAllCoroutines(); } }
/// <summary> /// /// </summary> private void Update() { _model.Step(); _stepCount++; // Debug.Log($"{_stepCount} steps taken!"); int[,] state = _model.CurrentState; // update cells based on current state of model for (int y = 0; y < _countY; y++) { for (int x = 0; x < _countX; x++) { _cells[y, x].State = state[y, x]; _cells[y, x].Age = state[y, x] > 0 ? _cells[y, x].Age + 1 : 0; } } // update cells age var _density = CalculateDensity(); // Debug.Log("density =" +_density); displayColor = DisplayColor(); StartCoroutine(displayColor); if (Time.time > 5) { StopCoroutine(DisplayColor()); StopAllCoroutines(); } }
/// <summary> /// /// </summary> private void Update() { _model.Step(); _stepCount++; //Debug.Log($"{_stepCount} steps taken!"); int[,] state = _model.CurrentState; // update cells based on current state of model for (int y = 0; y < _countY; y++) { for (int x = 0; x < _countX; x++) { if (_cells[y, x].State == 1 && state[y, x] == 1) { _cells[y, x].Age += 1; } else if (_cells[y, x].State == 0 && state[y, x] == 1) { _cells[y, x].Age = 1; } else if (state[y, x] == 0) { _cells[y, x].Age = 0; } if (_cells[y, x].Age >= 5) { _cells[y, x].Age = 0; } _cells[y, x].State = state[y, x]; _cellList.Add(_cells[y, x]); _frameList.Add(_cellList); } } }