diff --git a/lab1/CellularAutomaton.cpp b/lab1/CellularAutomaton.cpp index c1b3aff..0a44b2b 100644 --- a/lab1/CellularAutomaton.cpp +++ b/lab1/CellularAutomaton.cpp @@ -3,8 +3,8 @@ CellularAutomaton::CellularAutomaton(int width, int height, bool fillWithRandom, BoundaryCondition boundaryCondition) : m_fieldWidth(width), m_fieldHeight(height), m_boundaryCondition(boundaryCondition) { - field.resize(m_fieldHeight, std::vector(m_fieldWidth, 0)); - fieldNextState.resize(m_fieldHeight, std::vector(m_fieldWidth, 0)); + m_field.resize(m_fieldHeight, std::vector(m_fieldWidth, 0)); + m_fieldNextState.resize(m_fieldHeight, std::vector(m_fieldWidth, 0)); if (fillWithRandom) initializeRandom(); else initializeManual(); @@ -21,7 +21,7 @@ void CellularAutomaton::initializeRandom() { for (int x = 0; x < m_fieldWidth; ++x) { - field[y][x] = dis(gen); + m_field[y][x] = dis(gen); } } } @@ -38,7 +38,7 @@ void CellularAutomaton::initializeManual() std::cout << "Клетка (" << x << ", " << y << "): "; int cellValue = inputNumber(0, 1); - field[y][x] = cellValue; + m_field[y][x] = cellValue; } } } @@ -56,12 +56,12 @@ int CellularAutomaton::getCellState(int x, int y) const case BOUNDARY_TOROIDAL: x = (x + m_fieldWidth) % m_fieldWidth; y = (y + m_fieldHeight) % m_fieldHeight; - return field[y][x]; + return m_field[y][x]; default: return 0; } } - return field[y][x]; + return m_field[y][x]; } int CellularAutomaton::getNeighborhoodIndex(int x, int y) const @@ -84,16 +84,16 @@ void CellularAutomaton::update() for (int x = 0; x < m_fieldWidth; ++x) { int neighborhood = getNeighborhoodIndex(x, y); - fieldNextState[y][x] = (functionValues >> neighborhood) & 1; + m_fieldNextState[y][x] = (m_functionValues >> neighborhood) & 1; } } - field.swap(fieldNextState); + m_field.swap(m_fieldNextState); } void CellularAutomaton::displayField() const { - for (const auto& row : field) + for (const auto& row : m_field) { for (const auto& cell : row) { diff --git a/lab1/CellularAutomaton.h b/lab1/CellularAutomaton.h index 7766b7a..b1bbf30 100644 --- a/lab1/CellularAutomaton.h +++ b/lab1/CellularAutomaton.h @@ -12,11 +12,11 @@ enum BoundaryCondition { class CellularAutomaton { - static const unsigned int functionValues = 25 * 11 * 2003 * 18 * 11; + static const unsigned int m_functionValues = 25 * 11 * 2003 * 18 * 11; int m_fieldWidth, m_fieldHeight; - std::vector> field; - std::vector> fieldNextState; + std::vector> m_field; + std::vector> m_fieldNextState; BoundaryCondition m_boundaryCondition; void initializeRandom();