Skip to content

Commit

Permalink
Alteration to survive
Browse files Browse the repository at this point in the history
Stop taking snapshots of the pattern a fixed amount of time after the
last interaction begins.
  • Loading branch information
ceebo committed Nov 3, 2015
1 parent 6aa790e commit 8067e38
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions survive.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ main(int argc, char *argv[]) {
int fail;
int damaged;
int restored;
int firstgen;
int maxgen;
int prodcells;
int restorefilter=10;
char outpat[100000];
Expand Down Expand Up @@ -59,6 +61,8 @@ main(int argc, char *argv[]) {
fail=0;
damaged=0;
restored=0;
firstgen=0;
maxgen=0;
for (i=0; i<gens; i++) {
generate(&cells);

Expand All @@ -82,14 +86,18 @@ main(int argc, char *argv[]) {
|| matchLifeList(&cells, &boundarycells, 0) != matchcells.ncells) {
fail++;
restored=0;
if (firstgen == 0) { firstgen = i; maxgen = i + 10; }
} else {
prodcells = cells.ncells - matchcells.ncells;
copyLifeList(&cells, &outcells);

if (restored == 0 || i <= maxgen) {
prodcells = cells.ncells - matchcells.ncells;
copyLifeList(&cells, &outcells);
}

restored++;
if (restored>restorefilter) {
if (fail>damaged) damaged=fail;
fail = 0;
firstgen = 0;
}
}

Expand Down

0 comments on commit 8067e38

Please sign in to comment.