From 3d8453bdf79eda43c75f76a4f21d0a0e7cec76ec Mon Sep 17 00:00:00 2001 From: Arity-T Date: Thu, 5 Dec 2024 14:11:44 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20?= =?UTF-8?q?=D0=BF=D1=80=D0=B5=D1=84=D0=B8=D0=BA=D1=81=20=D0=BA=D0=BE=20?= =?UTF-8?q?=D0=B2=D1=81=D0=B5=D0=BC=20=D0=B0=D1=82=D1=80=D0=B8=D0=B1=D1=83?= =?UTF-8?q?=D1=82=D0=B0=D0=BC=20=D0=BA=D0=BB=D0=B0=D1=81=D1=81=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lab1/CellularAutomaton.cpp | 18 +++++++++--------- lab1/CellularAutomaton.h | 6 +++--- 2 files changed, 12 insertions(+), 12 deletions(-) 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();