mirror of
				https://gitlab.com/klmp200/LO27.git
				synced 2025-10-31 03:23:04 +00:00 
			
		
		
		
	Fix du doublon d'apply rules
This commit is contained in:
		| @@ -35,10 +35,7 @@ Matrix applyRules (Matrix matrix,int Rules, int N){ | ||||
| 		tempMatrix2 = matrixFromRules(tempMatrix1,i, RulesMatrix); | ||||
| 		freeMatrix(tempMatrix1); | ||||
|  | ||||
| 		tempMatrix1.colCount = tempMatrix2.colCount; | ||||
| 		tempMatrix1.rowCount = tempMatrix2.rowCount; | ||||
| 		tempMatrix1.cols = tempMatrix2.cols; | ||||
| 		tempMatrix1.rows = tempMatrix2.rows; | ||||
| 		tempMatrix1 = tempMatrix2; | ||||
| 	} | ||||
|  | ||||
| 	return tempMatrix1; | ||||
| @@ -621,46 +618,6 @@ 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; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user