1
0
mirror of https://gitlab.com/klmp200/LO27.git synced 2025-07-17 17:09:23 +00:00

finished applyrules

This commit is contained in:
Naej
2016-12-29 01:40:50 +01:00
parent 3df77c90ae
commit bfbee069ac
2 changed files with 44 additions and 15 deletions

View File

@ -4,24 +4,46 @@
#include <time.h>
Matrix applyRules (Matrix matrix,int Rules, int N){
int power = 2;
int RulesMatrix[9];
int i = 0;
if (Rules <= 0){
int power = 2;
int sum = 0;
int j = 0;
Matrix tempMatrix;
if (Rules <= 0 || N < 1){
return matrix;
} else {
while (Rules%power == 0 ){
power*=2;
}
for (i=0;i<N;i++){
printf("Apply rule %d \n",Rules%power);
/*Replace it by the implementation of the rules*/
}
tempMatrix = CreateMatrix();
while(power<=512){
RulesMatrix[i] = Rules%power - sum;
sum = Rules%power;
if (RulesMatrix[i]!=0){
i++;
}
applyRules(matrix,Rules - Rules%power,N);
power*=2;
}
return matrix;
/* test code : print decomposition */
/*for (j=0;j<i;j++){
printf("%d +",RulesMatrix[j]);
}*/
for (j = 0;j<N;j++){
freeMatrix(tempMatrix);
tempMatrix = matrixFromRules(matrix,i, RulesMatrix);
}
return tempMatrix;
}
Matrix CreateMatrix(){
Matrix matrix;
matrix.colCount = 0;