From 3f4a1487c49945282e2713b3e8f4dea9e078816d Mon Sep 17 00:00:00 2001 From: Micke Nordin Date: Sun, 30 Oct 2016 13:04:02 +0100 Subject: [PATCH] Faster generations --- ca.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/ca.cpp b/ca.cpp index 7ddbe15..1c17826 100644 --- a/ca.cpp +++ b/ca.cpp @@ -95,14 +95,23 @@ int main(int argc, char* argv[] ) { // Set up the initial condition int initial[DIM][DIM]; + int row = rand() % DIM; + int column = rand() % DIM; for(int i = 0; i < DIM; i++) { for(int j = 0; j < DIM; j++) { - if(i == HALF && j == HALF ) { + if(i == DIM -1 && j == HALF ) { initial[i][j] = 1; } else { initial[i][j] = 0; } - //initial[i][j] = rand() % 1; + + //initial[i][j] = rand() % 2; + + /*if(i == column && j == row ) { + initial[i][j] = 1; + } else { + initial[i][j] = 0; + }*/ } } @@ -115,8 +124,8 @@ int main(int argc, char* argv[] ) { cout << "Rule: " << rule << " generation: " << i << endl; // Print the current state print_arr(initial); - // Sleep 0.5 seconds - usleep(500000); + // Sleep 0.05 seconds + usleep(50000); // The next state int next[DIM][DIM];