Files
algorithm/lab1/CellularAutomaton.h

34 lines
732 B
C++

#pragma once
#include <vector>
#include <random>
#include <iostream>
#include "io.h"
enum BoundaryCondition {
BOUNDARY_ONES,
BOUNDARY_ZEROS,
BOUNDARY_TOROIDAL
};
class CellularAutomaton
{
static const unsigned int functionValues = 0b00000110100000000010110010110110;
int m_fieldWidth, m_fieldHeight;
std::vector<std::vector<int>> field;
std::vector<std::vector<int>> fieldNextState;
BoundaryCondition m_boundaryCondition;
void initializeRandom();
void initializeManual();
int getCellState(int x, int y) const;
int getNeighborhoodIndex(int x, int y) const;
public:
CellularAutomaton(int width, int height, bool fillWithRandom, BoundaryCondition boundaryCondition);
void update();
void displayField() const;
};