2016-12-13 14:55:42 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2016-12-13 14:12:55 +00:00
|
|
|
#include <CellElement.h>
|
|
|
|
#include <matrix.h>
|
2016-12-13 14:55:42 +00:00
|
|
|
|
|
|
|
Matrix applyRules (Matrix matrix,int Rules, int N){
|
2016-12-13 14:12:55 +00:00
|
|
|
int power = 2;
|
2016-12-13 14:55:42 +00:00
|
|
|
int i = 0;
|
|
|
|
if (Rules <= 0){
|
|
|
|
return matrix;
|
|
|
|
} else {
|
2016-12-13 14:12:55 +00:00
|
|
|
while (Rules%power == 0 ){
|
|
|
|
power*=2;
|
2016-12-13 14:55:42 +00:00
|
|
|
}
|
|
|
|
for (i=0;i<N;i++){
|
2016-12-13 14:12:55 +00:00
|
|
|
printf("Apply rule %d \n",Rules%power);
|
2016-12-13 14:55:42 +00:00
|
|
|
/*Replace it by the implementation of the rules*/
|
2016-12-13 14:12:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
applyRules(matrix,Rules - Rules%power,N);
|
2016-12-13 14:55:42 +00:00
|
|
|
}
|
|
|
|
return matrix;
|
|
|
|
}
|