Выбор заполнения
This commit is contained in:
@@ -1,12 +1,12 @@
|
|||||||
#include "CellularAutomaton.h"
|
#include "CellularAutomaton.h"
|
||||||
|
|
||||||
CellularAutomaton::CellularAutomaton(int width, int height) : m_fieldWidth(width), m_fieldHeight(height)
|
CellularAutomaton::CellularAutomaton(int width, int height, bool fillWithRandom) : m_fieldWidth(width), m_fieldHeight(height)
|
||||||
{
|
{
|
||||||
field.resize(m_fieldHeight, std::vector<int>(m_fieldWidth, 0));
|
field.resize(m_fieldHeight, std::vector<int>(m_fieldWidth, 0));
|
||||||
fieldNextState.resize(m_fieldHeight, std::vector<int>(m_fieldWidth, 0));
|
fieldNextState.resize(m_fieldHeight, std::vector<int>(m_fieldWidth, 0));
|
||||||
|
|
||||||
//initializeRandom();
|
if (fillWithRandom) initializeRandom();
|
||||||
initializeManual();
|
else initializeManual();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ class CellularAutomaton
|
|||||||
int getCellState(int x, int y) const;
|
int getCellState(int x, int y) const;
|
||||||
int getNeighborhoodIndex(int x, int y) const;
|
int getNeighborhoodIndex(int x, int y) const;
|
||||||
public:
|
public:
|
||||||
CellularAutomaton(int width, int height);
|
CellularAutomaton(int width, int height, bool fillWithRandom);
|
||||||
|
|
||||||
void update();
|
void update();
|
||||||
void displayField() const;
|
void displayField() const;
|
||||||
|
|||||||
@@ -40,9 +40,11 @@ int main()
|
|||||||
cout << "Укажите количество итераций (min 1): ";
|
cout << "Укажите количество итераций (min 1): ";
|
||||||
int iterationsCount = inputNumber(1);
|
int iterationsCount = inputNumber(1);
|
||||||
|
|
||||||
clear();
|
cout << "Заполнить поле случайными значениями? (yes/no)\n";
|
||||||
|
bool fillWithRandom = userApprove();
|
||||||
|
|
||||||
CellularAutomaton ca(fieldWidth, fieldHeight);
|
CellularAutomaton ca(fieldWidth, fieldHeight, fillWithRandom);
|
||||||
|
clear();
|
||||||
|
|
||||||
std::cout << "\nИтерация 0:\n";
|
std::cout << "\nИтерация 0:\n";
|
||||||
ca.displayField();
|
ca.displayField();
|
||||||
|
|||||||
Reference in New Issue
Block a user