This is C++ implementation of the Conway's Game of Life.
You need at least C++11 compiler.
make
./gol
- Watch evolution from random state till we hit stationary state:
auto field = Field(70, 30);
field.randomize(0.2);
for (;;) {
cout << field;
int num_updates = field.update();
cout << "Number of updates: " << num_updates << endl;
if (num_updates == 0) break;
this_thread::sleep_for(chrono::milliseconds(100));
}
- Count repeat period of Pulsar pattern:
auto pulsar = Field(20, 20);
pulsar.set_pattern(PULSAR);
auto pulsar_start = pulsar;
int epoch = 0;
do {
pulsar.update();
epoch++;
} while (pulsar != pulsar_start);
cout << "Pulsar repeats in " << epoch << " epochs." << endl;
- Meditate on Gosper Glider Gun:
auto field = Field(70, 30);
field.set_pattern(GOSPER_GLIDER_GUN);
for (;;) {
cout << field << endl;
field.update();
this_thread::sleep_for(chrono::milliseconds(100));
}