1
0
mirror of https://gitlab.com/klmp200/LO27.git synced 2024-11-26 02:04:14 +00:00

fait les fx de merde demandées

This commit is contained in:
Naej 2016-12-29 15:25:02 +01:00 committed by klmp200
parent 758e64f6cd
commit 281adf9893
2 changed files with 133 additions and 4 deletions

View File

@ -621,10 +621,121 @@ bool * GetFromRules(Matrix m, int ColPos, int RowPos, int n, int rules[]){
}
Matrix applyRules (Matrix matrix,int Rules, int N){
int RulesMatrix[9];
int i = 0;
int power = 2;
int sum = 0;
int j = 0;
Matrix tempMatrix;
if (Rules <= 0 || N < 1){
return matrix;
}
tempMatrix = CreateMatrix();
while(power<=512){
RulesMatrix[i] = Rules%power - sum;
sum = Rules%power;
if (RulesMatrix[i]!=0){
i++;
}
power*=2;
}
/* 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;
}
bool isMatrixEmpty(Matrix matrix){
if (matrix.colCount < 1 || matrix.rowCount < 1){
return true;
}
if (matrix.cols->size == 0 || matrix.rows->size == 0){
return true;
}
return false;
}
bool isMatrixSquare(Matrix matrix){
if (matrix.colCount == matrix.rowCount){
return true;
}
return false;
}
bool isColumnEmpty(Matrix matrix,int nb){
ListElement * Col = NULL;
if (matrix.colCount < 1 || matrix.rowCount < 1){
return true;
}
if (matrix.cols->size == 0 || matrix.rows->size == 0){
return true;
}
Col = GetElementPos(matrix.cols,nb);
if (Col == NULL || Col->data == NULL){
return true;
}
return false;
}
bool isRowEmpty(Matrix matrix,int nb){
ListElement * Row = NULL;
if (matrix.colCount < 1 || matrix.rowCount < 1){
return true;
}
if (matrix.cols->size == 0 || matrix.rows->size == 0){
return true;
}
Row = GetElementPos(matrix.rows,nb);
if (Row == NULL || Row->data == NULL){
return true;
}
return false;
}
bool equalsMatrix(Matrix m1, Matrix m2){
int i = 0;
int j = 0;
if (m1.colCount == m2.colCount && m1.rowCount == m2.rowCount){
for (i=0;i<m2.colCount;i++){
for (j=0;j<m1.rowCount;j++){
if (GetCellValue(m1,i,j)!=GetCellValue(m2,i,j)){
return false;
}
}
}
}else{
return false;
}
return true;
}
/* todos :
*mulMatrix
*
*chasser les bugs
*faire les fontions débiles qui restent
*ecrire doc
*faire un print + opti pour que sli l'adapte avec sdl
*/

View File

@ -340,8 +340,26 @@ bool bottom_rightRule(Matrix m, int ColPos, int RowPos);
*/
bool * GetFromRules(Matrix m, int ColPos, int RowPos, int n, int rules[]);
/*---applyRules---
*A function tha allows you to apply some rules n times on the matrix and returns it
*
*@matrix : A matrix on whitch you would apply the rules
*
*@Rules : Integer describing the rules
*
*@N : number of time the rules will be applied
*
*/
Matrix applyRules(Matrix matrix,int Rules, int N);
Matrix sumMatrix(Matrix matrix1,Matrix matrix2);
Matrix mulMatrix(Matrix matrix1,Matrix matrix2);
bool isMatrixEmpty(Matrix matrix);
bool isMatrixSquare(Matrix matrix);
bool isColumnEmpty(Matrix matrix,int nb);
bool isRowEmpty(Matrix matrix,int nb);
bool equalsMatrix(Matrix m1, Matrix m2);
#endif