65 lines
1.5 KiB
C++
65 lines
1.5 KiB
C++
#include <iostream>
|
|
#include "io.h"
|
|
#include "CellularAutomaton.h"
|
|
|
|
using namespace std;
|
|
|
|
void clear() {
|
|
system("cls");
|
|
cout << "Вариант: 00000110100000000010110010110110\n\n";
|
|
}
|
|
|
|
|
|
int main()
|
|
{
|
|
setlocale(LC_ALL, "Russian");
|
|
|
|
while (true) {
|
|
clear();
|
|
|
|
cout << "Выберите граничные условия:\n"
|
|
"Единичные (0)\n"
|
|
"Нулевые (1)\n"
|
|
"Тороидальные (2)\n"
|
|
"Завершить работу (3)\n\n";
|
|
int actionId = inputNumber(0, 3);
|
|
|
|
clear();
|
|
|
|
if (actionId == 3) {
|
|
cout << "Выйти из программы? (yes/no)\n";
|
|
if (userApprove()) return 0;
|
|
continue;
|
|
}
|
|
|
|
BoundaryCondition boundaryCondition = static_cast<BoundaryCondition>(actionId);
|
|
|
|
cout << "Укажите ширину поля (min 1): ";
|
|
int fieldWidth = inputNumber(1);
|
|
|
|
cout << "Укажите высоту поля (min 1): ";
|
|
int fieldHeight = inputNumber(1);
|
|
|
|
cout << "Укажите количество итераций (min 1): ";
|
|
int iterationsCount = inputNumber(1);
|
|
|
|
cout << "Заполнить поле случайными значениями? (yes/no)\n";
|
|
bool fillWithRandom = userApprove();
|
|
|
|
CellularAutomaton ca(fieldWidth, fieldHeight, fillWithRandom, boundaryCondition);
|
|
clear();
|
|
|
|
cout << "\nИтерация 0:\n";
|
|
ca.displayField();
|
|
|
|
for (int i = 0; i < iterationsCount; ++i)
|
|
{
|
|
cout << "\nИтерация " << i + 1 << ":\n";
|
|
ca.update();
|
|
ca.displayField();
|
|
}
|
|
|
|
cout << "\nНажмите на enter, чтобы продолжить...";
|
|
waitForEnter();
|
|
}
|
|
} |