1
0
mirror of https://gitlab.com/klmp200/LO27.git synced 2024-11-05 12:38:04 +00:00
LO27/LibAutomaton/matrix.c

33 lines
603 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;
}
2016-12-13 16:28:13 +00:00
Matrix CreateMatrix(){
Matrix matrix;
matrix.colCount = 0;
matrix.rowCount = 0;
matrix.cols = CreateList();
matrix.rows = CreateList();
return matrix;
}