1
0
mirror of https://gitlab.com/klmp200/LO27.git synced 2024-11-16 21:13:18 +00:00
LO27/LibAutomaton/matrix.c

24 lines
443 B
C
Raw Normal View History

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