Добавил префикс ко всем атрибутам класса
This commit is contained in:
@@ -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<int>(m_fieldWidth, 0));
|
||||
fieldNextState.resize(m_fieldHeight, std::vector<int>(m_fieldWidth, 0));
|
||||
m_field.resize(m_fieldHeight, std::vector<int>(m_fieldWidth, 0));
|
||||
m_fieldNextState.resize(m_fieldHeight, std::vector<int>(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 << "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (" << 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)
|
||||
{
|
||||
|
||||
@@ -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<std::vector<int>> field;
|
||||
std::vector<std::vector<int>> fieldNextState;
|
||||
std::vector<std::vector<int>> m_field;
|
||||
std::vector<std::vector<int>> m_fieldNextState;
|
||||
BoundaryCondition m_boundaryCondition;
|
||||
|
||||
void initializeRandom();
|
||||
|
||||
Reference in New Issue
Block a user