Skip to content

alexander-travov/gol_cpp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Conway's Game of Life

Pulsar

This is C++ implementation of the Conway's Game of Life.

You need at least C++11 compiler.

Building

make
./gol

Examples

  1. 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));
}
  1. 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;
  1. 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));
}

Releases

No releases published

Packages

No packages published