Comments and minor fix

This commit is contained in:
karl 2020-10-21 18:49:03 +02:00
parent 8015d16dac
commit 75588b85cd

View File

@ -6,6 +6,9 @@
#define DEAD_CELL 0 // '.' in the input data
#define NUM_GENERATIONS 250
// Using this struct seems to be more performant than just passing
// a bool** around functions. However, also adding the neighbor_count
// made performance worse.
struct World {
World(int size_x, int size_y) : size_x(size_x), size_y(size_y) {
data = new bool*[size_y];
@ -154,15 +157,15 @@ int main() {
world_file.close();
timing->stopSetup();
timing->startComputation();
// In this separate array, we keep track of how many live neighbors
// a certain cell has. This is because immediately updating based
// on the number of neighbors would mess with later calculations
// of adjacent cells.
int *neighbor_counts = new int[world.size_y * world.size_x];
timing->stopSetup();
timing->startComputation();
// Do some generations
for (int i = 0; i < NUM_GENERATIONS; i++) {
generation(world, neighbor_counts);