mirror of
https://gitlab.com/klmp200/LO27.git
synced 2024-12-22 18:01:08 +00:00
Renommage complet des fonctions
This commit is contained in:
parent
28021951b4
commit
d763abfc80
30
LibGui/gui.c
30
LibGui/gui.c
@ -27,7 +27,7 @@
|
||||
#include <termios.h>
|
||||
#include <unistd.h>
|
||||
|
||||
void SetPixel(SDL_Renderer *renderer, int x, int y, bool value){
|
||||
void setPixel(SDL_Renderer *renderer, int x, int y, bool value){
|
||||
|
||||
if (value){
|
||||
SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255);
|
||||
@ -37,7 +37,7 @@ void SetPixel(SDL_Renderer *renderer, int x, int y, bool value){
|
||||
SDL_RenderDrawPoint(renderer, x, y);
|
||||
}
|
||||
|
||||
void DisplayMatrixSDL(SCREEN *screen, Matrix m){
|
||||
void displayMatrixSDL(SCREEN *screen, Matrix m){
|
||||
int i;
|
||||
int j;
|
||||
|
||||
@ -46,13 +46,13 @@ void DisplayMatrixSDL(SCREEN *screen, Matrix m){
|
||||
|
||||
for (i=0;i<m.rowCount;i++){
|
||||
for (j=0;j<m.colCount;j++){
|
||||
SetPixel(screen->renderer, i, j, GetCellValue(m, j, i));
|
||||
setPixel(screen->renderer, i, j, getCellValue(m, j, i));
|
||||
}
|
||||
}
|
||||
SDL_RenderPresent(screen->renderer);
|
||||
}
|
||||
|
||||
void WaitUntilEnter(SCREEN * screen){
|
||||
void waitUntilEnter(SCREEN * screen){
|
||||
int keypress = 0;
|
||||
|
||||
while (!keypress){
|
||||
@ -72,7 +72,7 @@ void WaitUntilEnter(SCREEN * screen){
|
||||
}
|
||||
}
|
||||
|
||||
int NewWindowFromMatrix(Matrix m){
|
||||
int newWindowFromMatrix(Matrix m){
|
||||
SCREEN screen;
|
||||
|
||||
screen.WIDTH = m.colCount;
|
||||
@ -92,9 +92,9 @@ int NewWindowFromMatrix(Matrix m){
|
||||
return 1;
|
||||
}
|
||||
|
||||
DisplayMatrixSDL(&screen, m);
|
||||
displayMatrixSDL(&screen, m);
|
||||
|
||||
WaitUntilEnter(&screen);
|
||||
waitUntilEnter(&screen);
|
||||
|
||||
SDL_DestroyRenderer(screen.renderer);
|
||||
SDL_DestroyWindow(screen.window);
|
||||
@ -104,12 +104,12 @@ int NewWindowFromMatrix(Matrix m){
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool YesOrNo(char message[]){
|
||||
bool inputYesOrNo(char message[]){
|
||||
char response;
|
||||
|
||||
printf("%s (Y/n)\n", message);
|
||||
response = getchar();
|
||||
ClearBuffer();
|
||||
clearBuffer();
|
||||
|
||||
if (response == 'n'){
|
||||
return false;
|
||||
@ -119,33 +119,33 @@ bool YesOrNo(char message[]){
|
||||
|
||||
}
|
||||
|
||||
void ClearBuffer(){
|
||||
void clearBuffer(){
|
||||
char c;
|
||||
while ((c = getchar()) != '\n' && c != EOF) { }
|
||||
}
|
||||
|
||||
void DisplayMatrixGUI(Matrix m, bool useSDL){
|
||||
void displayMatrixGUI(Matrix m, bool useSDL){
|
||||
if (useSDL){
|
||||
printf("Press ENTER or the red cross to exit the window and continue.\n");
|
||||
NewWindowFromMatrix(m);
|
||||
newWindowFromMatrix(m);
|
||||
} else {
|
||||
printMatrix(m);
|
||||
}
|
||||
}
|
||||
|
||||
int SafeNumberInput(int min, int max){
|
||||
int safeNumberInput(int min, int max){
|
||||
char str[30];
|
||||
int input;
|
||||
|
||||
fgets(str, 29, stdin);
|
||||
ClearBuffer();
|
||||
clearBuffer();
|
||||
|
||||
input = atoi(str);
|
||||
|
||||
while (input < min || input > max){
|
||||
printf("The number should be between %d and %d\n", min, max);
|
||||
fgets(str, 29, stdin);
|
||||
ClearBuffer();
|
||||
clearBuffer();
|
||||
input = atoi(str);
|
||||
}
|
||||
|
||||
|
16
LibGui/gui.h
16
LibGui/gui.h
@ -41,7 +41,7 @@ typedef struct {
|
||||
* @param value display white if true and black if false
|
||||
* @return
|
||||
*/
|
||||
void SetPixel(SDL_Renderer *renderer, int x, int y, bool value);
|
||||
void setPixel(SDL_Renderer *renderer, int x, int y, bool value);
|
||||
|
||||
/**
|
||||
* Display an entire matrix on a given screen
|
||||
@ -49,28 +49,28 @@ void SetPixel(SDL_Renderer *renderer, int x, int y, bool value);
|
||||
* @param m a Matrix
|
||||
* @return
|
||||
*/
|
||||
void DisplayMatrixSDL(SCREEN *screen, Matrix m);
|
||||
void displayMatrixSDL(SCREEN *screen, Matrix m);
|
||||
|
||||
/**
|
||||
* Wait until the user press the enter key
|
||||
* @param screen the screen where the renderer is
|
||||
* @return
|
||||
*/
|
||||
void WaitUntilEnter(SCREEN * screen);
|
||||
void waitUntilEnter(SCREEN * screen);
|
||||
|
||||
/**
|
||||
* Print a matrix in a new SDL window
|
||||
* @param Matrix the matrix to display
|
||||
* @return int error code
|
||||
*/
|
||||
int NewWindowFromMatrix(Matrix m);
|
||||
int newWindowFromMatrix(Matrix m);
|
||||
|
||||
/**
|
||||
* Display a message and ask for yes or no to the user
|
||||
* @param message the message to display
|
||||
* @return bool the answer
|
||||
*/
|
||||
bool YesOrNo(char message[]);
|
||||
bool inputYesOrNo(char message[]);
|
||||
|
||||
/**
|
||||
* Display matrix choosing the right function
|
||||
@ -78,7 +78,7 @@ bool YesOrNo(char message[]);
|
||||
* @param useSDL a bool
|
||||
* @return
|
||||
*/
|
||||
void DisplayMatrixGUI(Matrix m, bool useSDL);
|
||||
void displayMatrixGUI(Matrix m, bool useSDL);
|
||||
|
||||
/**
|
||||
* Get a number from the user safely
|
||||
@ -86,12 +86,12 @@ void DisplayMatrixGUI(Matrix m, bool useSDL);
|
||||
* @param max the maximal authorized number
|
||||
* @return int the input number
|
||||
*/
|
||||
int SafeNumberInput(int min, int max);
|
||||
int safeNumberInput(int min, int max);
|
||||
|
||||
/**
|
||||
* Clears the buffer of stdin
|
||||
* @return
|
||||
*/
|
||||
void ClearBuffer();
|
||||
void clearBuffer();
|
||||
|
||||
#endif
|
||||
|
@ -51,7 +51,6 @@ Matrix applyRules (Matrix matrix,int Rules, int N){
|
||||
tempMatrix1 = matrixFromRules(matrix, i, RulesMatrix);
|
||||
|
||||
for (j=1;j<N;j++){
|
||||
printf("Tourne\n");
|
||||
tempMatrix2 = matrixFromRules(tempMatrix1,i, RulesMatrix);
|
||||
freeMatrix(tempMatrix1);
|
||||
|
||||
@ -63,7 +62,7 @@ Matrix applyRules (Matrix matrix,int Rules, int N){
|
||||
}
|
||||
|
||||
|
||||
Matrix CreateMatrix(){
|
||||
Matrix createMatrix(){
|
||||
Matrix matrix;
|
||||
matrix.colCount = 0;
|
||||
matrix.rowCount = 0;
|
||||
@ -72,13 +71,13 @@ Matrix CreateMatrix(){
|
||||
return matrix;
|
||||
}
|
||||
|
||||
Matrix SetMatrixDim(Matrix matrix,int nbCols,int nbRows){
|
||||
Matrix setMatrixDim(Matrix matrix,int nbCols,int nbRows){
|
||||
matrix.colCount = nbCols;
|
||||
matrix.rowCount = nbRows;
|
||||
return matrix;
|
||||
}
|
||||
|
||||
bool CreateMatrixElem(Matrix matrix, int ColPos, int RowPos){
|
||||
bool createMatrixElem(Matrix matrix, int ColPos, int RowPos){
|
||||
ListElement * Row = NULL;
|
||||
ListElement * Col = NULL;
|
||||
int error = 0;
|
||||
@ -153,7 +152,7 @@ bool CreateMatrixElem(Matrix matrix, int ColPos, int RowPos){
|
||||
|
||||
}
|
||||
|
||||
cellElement * FindMatrixElem(Matrix matrix, int ColPos, int RowPos){
|
||||
cellElement * findMatrixElem(Matrix matrix, int ColPos, int RowPos){
|
||||
ListElement * Row = NULL;
|
||||
cellElement * elem = NULL;
|
||||
|
||||
@ -170,14 +169,14 @@ cellElement * FindMatrixElem(Matrix matrix, int ColPos, int RowPos){
|
||||
return elem;
|
||||
}
|
||||
|
||||
int SupprMatrixElem(Matrix matrix, int ColPos, int RowPos){
|
||||
int deleteMatrixElem(Matrix matrix, int ColPos, int RowPos){
|
||||
cellElement * elem = NULL;
|
||||
cellElement * tmp = NULL;
|
||||
|
||||
ListElement * Row = NULL;
|
||||
ListElement * Col = NULL;
|
||||
|
||||
elem = FindMatrixElem(matrix,ColPos,RowPos);
|
||||
elem = findMatrixElem(matrix,ColPos,RowPos);
|
||||
if (elem == NULL){
|
||||
return 0;
|
||||
}
|
||||
@ -240,22 +239,22 @@ int SupprMatrixElem(Matrix matrix, int ColPos, int RowPos){
|
||||
|
||||
}
|
||||
|
||||
bool GetCellValue(Matrix matrix, int ColPos, int RowPos){
|
||||
bool getCellValue(Matrix matrix, int ColPos, int RowPos){
|
||||
if (matrix.colCount <= ColPos || matrix.rowCount <= RowPos){
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
if (FindMatrixElem(matrix,ColPos,RowPos) == NULL){
|
||||
if (findMatrixElem(matrix,ColPos,RowPos) == NULL){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SetCellValue(Matrix matrix, int ColPos, int RowPos,bool value){
|
||||
bool setCellValue(Matrix matrix, int ColPos, int RowPos,bool value){
|
||||
if (value == true){
|
||||
return CreateMatrixElem(matrix,ColPos,RowPos);
|
||||
return createMatrixElem(matrix,ColPos,RowPos);
|
||||
}else{
|
||||
if ( SupprMatrixElem(matrix,ColPos,RowPos) >= 0 ){
|
||||
if ( deleteMatrixElem(matrix,ColPos,RowPos) >= 0 ){
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
@ -275,7 +274,7 @@ void printMatrix(Matrix matrix){
|
||||
printf("| ");
|
||||
for (j=0;j<matrix.colCount;j++){
|
||||
|
||||
b = GetCellValue(matrix,j,i);
|
||||
b = getCellValue(matrix,j,i);
|
||||
if (b == true){
|
||||
printf("1 ");
|
||||
}else if (b == false){
|
||||
@ -299,7 +298,7 @@ Matrix freeMatrix(Matrix matrix){
|
||||
for (i=0;i<matrix.rowCount;i++){
|
||||
for (j=0;j<matrix.colCount;j++){
|
||||
|
||||
SetCellValue(matrix,j,i,false);
|
||||
setCellValue(matrix,j,i,false);
|
||||
|
||||
|
||||
}
|
||||
@ -312,15 +311,15 @@ Matrix freeMatrix(Matrix matrix){
|
||||
}
|
||||
|
||||
Matrix opMatrix(Matrix matrix1,Matrix matrix2,bool (operator)(bool, bool)){
|
||||
Matrix SumMatrix = CreateMatrix();
|
||||
Matrix SumMatrix = createMatrix();
|
||||
int i =0;
|
||||
int j = 0;
|
||||
|
||||
if (matrix1.colCount == matrix2.colCount && matrix1.rowCount == matrix2.rowCount){
|
||||
SumMatrix = SetMatrixDim(SumMatrix,matrix2.colCount,matrix1.rowCount);
|
||||
SumMatrix = setMatrixDim(SumMatrix,matrix2.colCount,matrix1.rowCount);
|
||||
for (i=0;i<SumMatrix.colCount;i++){
|
||||
for (j=0;j<SumMatrix.rowCount;j++){
|
||||
SetCellValue(SumMatrix,i,j,operator(GetCellValue(matrix1,i,j),GetCellValue(matrix2,i,j)));
|
||||
setCellValue(SumMatrix,i,j,operator(getCellValue(matrix1,i,j),getCellValue(matrix2,i,j)));
|
||||
|
||||
}
|
||||
}
|
||||
@ -349,7 +348,7 @@ Matrix colSequenceOnMatrix(Matrix m, bool (operator)(bool, bool)){
|
||||
bool b;
|
||||
int i;
|
||||
int j;
|
||||
Matrix newM = CreateMatrix();
|
||||
Matrix newM = createMatrix();
|
||||
|
||||
|
||||
newM.rowCount = m.rowCount;
|
||||
@ -361,10 +360,10 @@ Matrix colSequenceOnMatrix(Matrix m, bool (operator)(bool, bool)){
|
||||
|
||||
for (i=0;i < m.colCount - 1;i++){
|
||||
for (j=0;j < m.rowCount;j++){
|
||||
a = GetCellValue(m, i, j);
|
||||
b = GetCellValue(m, i + 1, j);
|
||||
a = getCellValue(m, i, j);
|
||||
b = getCellValue(m, i + 1, j);
|
||||
if (operator(a, b)){
|
||||
SetCellValue(newM, i, j, true);
|
||||
setCellValue(newM, i, j, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -376,7 +375,7 @@ Matrix rowSequenceOnMatrix(Matrix m, bool (operator)(bool, bool)){
|
||||
bool b;
|
||||
int i;
|
||||
int j;
|
||||
Matrix newM = CreateMatrix();
|
||||
Matrix newM = createMatrix();
|
||||
|
||||
newM.colCount = m.colCount;
|
||||
if (m.rowCount <= 1){
|
||||
@ -387,10 +386,10 @@ Matrix rowSequenceOnMatrix(Matrix m, bool (operator)(bool, bool)){
|
||||
|
||||
for (i=0; i < m.colCount;i++){
|
||||
for (j=0;j < m.rowCount - 1;j++){
|
||||
a = GetCellValue(m, i, j);
|
||||
b = GetCellValue(m, i, j + 1);
|
||||
a = getCellValue(m, i, j);
|
||||
b = getCellValue(m, i, j + 1);
|
||||
if (operator(a, b)){
|
||||
SetCellValue(newM, i, j, true);
|
||||
setCellValue(newM, i, j, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -414,7 +413,7 @@ Matrix orRowSequenceOnMatrix(Matrix m){
|
||||
}
|
||||
|
||||
Matrix newMatrix(BooleanMatrix bmatrix){
|
||||
Matrix m = CreateMatrix();
|
||||
Matrix m = createMatrix();
|
||||
int i;
|
||||
int j;
|
||||
|
||||
@ -424,7 +423,7 @@ Matrix newMatrix(BooleanMatrix bmatrix){
|
||||
for (i=0; i < m.rowCount ; i++){
|
||||
for (j=0; j < m.colCount; j++){
|
||||
if (bmatrix.data[i][j]){
|
||||
SetCellValue(m, j, i, true);
|
||||
setCellValue(m, j, i, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -432,7 +431,7 @@ Matrix newMatrix(BooleanMatrix bmatrix){
|
||||
return m;
|
||||
}
|
||||
|
||||
BooleanMatrix CreateBooleanMatrix(int cols, int rows){
|
||||
BooleanMatrix createBooleanMatrix(int cols, int rows){
|
||||
BooleanMatrix matrix;
|
||||
int i;
|
||||
|
||||
@ -448,7 +447,7 @@ BooleanMatrix CreateBooleanMatrix(int cols, int rows){
|
||||
return matrix;
|
||||
}
|
||||
|
||||
BooleanMatrix RandomizeBooleanMatrix(BooleanMatrix matrix){
|
||||
BooleanMatrix randomizeBooleanMatrix(BooleanMatrix matrix){
|
||||
int i;
|
||||
int j;
|
||||
int r;
|
||||
@ -469,7 +468,7 @@ BooleanMatrix RandomizeBooleanMatrix(BooleanMatrix matrix){
|
||||
return matrix;
|
||||
}
|
||||
|
||||
void FreeBooleanMatrix(BooleanMatrix matrix){
|
||||
void freeBooleanMatrix(BooleanMatrix matrix){
|
||||
int i;
|
||||
for (i=0; i < matrix.rows; i++){
|
||||
free(matrix.data[i]);
|
||||
@ -483,7 +482,7 @@ Matrix matrixFromRules(Matrix m, int n, int rules[]){
|
||||
int j;
|
||||
|
||||
bool * bools = NULL;
|
||||
Matrix result = CreateMatrix();
|
||||
Matrix result = createMatrix();
|
||||
|
||||
if (rules == NULL){
|
||||
result.colCount = 0;
|
||||
@ -496,10 +495,10 @@ Matrix matrixFromRules(Matrix m, int n, int rules[]){
|
||||
|
||||
for (i=0; i < m.rowCount; i++){
|
||||
for (j = 0; j < m.colCount; j++){
|
||||
bools = GetFromRules(m, j, i, n, rules);
|
||||
bools = getFromRules(m, j, i, n, rules);
|
||||
if (bools != NULL){
|
||||
if (MXOR(n, bools)){
|
||||
SetCellValue(result, j, i, true);
|
||||
setCellValue(result, j, i, true);
|
||||
}
|
||||
free(bools);
|
||||
}
|
||||
@ -518,42 +517,42 @@ bool MXOR(int n, bool bools[]){
|
||||
}
|
||||
|
||||
bool firstRule(Matrix m, int ColPos, int RowPos){
|
||||
return ErrorToFalse(GetCellValue(m, ColPos, RowPos));
|
||||
return ErrorToFalse(getCellValue(m, ColPos, RowPos));
|
||||
}
|
||||
|
||||
bool leftRule(Matrix m, int ColPos, int RowPos){
|
||||
return ErrorToFalse(GetCellValue(m, ColPos + 1, RowPos));
|
||||
return ErrorToFalse(getCellValue(m, ColPos + 1, RowPos));
|
||||
}
|
||||
|
||||
bool rightRule(Matrix m, int ColPos, int RowPos){
|
||||
return ErrorToFalse(GetCellValue(m, ColPos - 1, RowPos));
|
||||
return ErrorToFalse(getCellValue(m, ColPos - 1, RowPos));
|
||||
}
|
||||
|
||||
bool topRule(Matrix m, int ColPos, int RowPos){
|
||||
return ErrorToFalse(GetCellValue(m, ColPos, RowPos + 1));
|
||||
return ErrorToFalse(getCellValue(m, ColPos, RowPos + 1));
|
||||
}
|
||||
|
||||
bool bottomRule(Matrix m, int ColPos, int RowPos){
|
||||
return ErrorToFalse(GetCellValue(m, ColPos, RowPos - 1));
|
||||
return ErrorToFalse(getCellValue(m, ColPos, RowPos - 1));
|
||||
}
|
||||
|
||||
bool top_leftRule(Matrix m, int ColPos, int RowPos){
|
||||
return ErrorToFalse(GetCellValue(m, ColPos + 1, RowPos + 1));
|
||||
bool topLeftRule(Matrix m, int ColPos, int RowPos){
|
||||
return ErrorToFalse(getCellValue(m, ColPos + 1, RowPos + 1));
|
||||
}
|
||||
|
||||
bool top_rightRule(Matrix m, int ColPos, int RowPos){
|
||||
return ErrorToFalse(GetCellValue(m, ColPos - 1, RowPos + 1));
|
||||
bool topRightRule(Matrix m, int ColPos, int RowPos){
|
||||
return ErrorToFalse(getCellValue(m, ColPos - 1, RowPos + 1));
|
||||
}
|
||||
|
||||
bool bottom_leftRule(Matrix m, int ColPos, int RowPos){
|
||||
return ErrorToFalse(GetCellValue(m, ColPos + 1, RowPos - 1));
|
||||
bool bottomLeftRule(Matrix m, int ColPos, int RowPos){
|
||||
return ErrorToFalse(getCellValue(m, ColPos + 1, RowPos - 1));
|
||||
}
|
||||
|
||||
bool bottom_rightRule(Matrix m, int ColPos, int RowPos){
|
||||
return ErrorToFalse(GetCellValue(m, ColPos - 1, RowPos - 1));
|
||||
bool bottomRightRule(Matrix m, int ColPos, int RowPos){
|
||||
return ErrorToFalse(getCellValue(m, ColPos - 1, RowPos - 1));
|
||||
}
|
||||
|
||||
bool * GetFromRules(Matrix m, int ColPos, int RowPos, int n, int rules[]){
|
||||
bool * getFromRules(Matrix m, int ColPos, int RowPos, int n, int rules[]){
|
||||
bool * bools = (bool *)malloc(sizeof(bool) * n);
|
||||
int i;
|
||||
|
||||
@ -573,16 +572,16 @@ bool * GetFromRules(Matrix m, int ColPos, int RowPos, int n, int rules[]){
|
||||
bools[i] = rightRule(m, ColPos, RowPos);
|
||||
break;
|
||||
case 4:
|
||||
bools[i] = top_leftRule(m, ColPos, RowPos);
|
||||
bools[i] = topLeftRule(m, ColPos, RowPos);
|
||||
break;
|
||||
case 16:
|
||||
bools[i] = top_rightRule(m, ColPos, RowPos);
|
||||
bools[i] = topRightRule(m, ColPos, RowPos);
|
||||
break;
|
||||
case 256:
|
||||
bools[i] = bottom_leftRule(m, ColPos, RowPos);
|
||||
bools[i] = bottomLeftRule(m, ColPos, RowPos);
|
||||
break;
|
||||
case 34:
|
||||
bools[i] = bottom_rightRule(m, ColPos, RowPos);
|
||||
bools[i] = bottomRightRule(m, ColPos, RowPos);
|
||||
break;
|
||||
case 1:
|
||||
bools[i] = firstRule(m, ColPos, RowPos);
|
||||
@ -653,7 +652,7 @@ bool equalsMatrix(Matrix m1, Matrix m2){
|
||||
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)){
|
||||
if (getCellValue(m1,i,j)!=getCellValue(m2,i,j)){
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@
|
||||
* @param rows is pointer on the first row that contains a true value
|
||||
* @param cols is pointer on the first col that contains a true value
|
||||
*
|
||||
* @see CreateMatrix to allocate one
|
||||
* @see createMatrix to allocate one
|
||||
* @see freeMatrix to free one
|
||||
*/
|
||||
typedef struct Matrix {
|
||||
@ -54,7 +54,7 @@ typedef struct Matrix {
|
||||
* @param cols numbers of columns of the matrix
|
||||
* @param data the matrix
|
||||
*
|
||||
* @see CreateBooleanMatrix to create one
|
||||
* @see createBooleanMatrix to create one
|
||||
*/
|
||||
typedef struct {
|
||||
int rows;
|
||||
@ -72,7 +72,7 @@ typedef struct {
|
||||
*
|
||||
* @return booleanmatrix a new matrix
|
||||
*/
|
||||
BooleanMatrix CreateBooleanMatrix(int cols, int rows);
|
||||
BooleanMatrix createBooleanMatrix(int cols, int rows);
|
||||
|
||||
/**
|
||||
* Randomize a BooleanMatrix
|
||||
@ -81,7 +81,7 @@ BooleanMatrix CreateBooleanMatrix(int cols, int rows);
|
||||
*
|
||||
* @return booleanmatrix the processed matrix
|
||||
*/
|
||||
BooleanMatrix RandomizeBooleanMatrix(BooleanMatrix matrix);
|
||||
BooleanMatrix randomizeBooleanMatrix(BooleanMatrix matrix);
|
||||
|
||||
/**
|
||||
* Free a BooleanMatrix
|
||||
@ -90,7 +90,7 @@ BooleanMatrix RandomizeBooleanMatrix(BooleanMatrix matrix);
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
void FreeBooleanMatrix(BooleanMatrix matrix);
|
||||
void freeBooleanMatrix(BooleanMatrix matrix);
|
||||
|
||||
/**
|
||||
* Create a Matrix from its array-based representation
|
||||
@ -118,7 +118,7 @@ Matrix applyRules(Matrix matrix,int Rules, int N);
|
||||
* @return a matrix
|
||||
*
|
||||
*/
|
||||
Matrix CreateMatrix();
|
||||
Matrix createMatrix();
|
||||
|
||||
/**
|
||||
* Find and return the cell in the given matrix
|
||||
@ -130,7 +130,7 @@ Matrix CreateMatrix();
|
||||
* @return a cellElement
|
||||
*
|
||||
*/
|
||||
cellElement * FindMatrixElem(Matrix matrix, int ColPos, int RowPos);
|
||||
cellElement * findMatrixElem(Matrix matrix, int ColPos, int RowPos);
|
||||
|
||||
/**
|
||||
* Create the cell in the given matrix
|
||||
@ -142,7 +142,7 @@ cellElement * FindMatrixElem(Matrix matrix, int ColPos, int RowPos);
|
||||
* @return a bool (error code)
|
||||
*
|
||||
*/
|
||||
bool CreateMatrixElem(Matrix matrix, int ColPos, int RowPos);
|
||||
bool createMatrixElem(Matrix matrix, int ColPos, int RowPos);
|
||||
|
||||
/**
|
||||
* Delete the cell in the given matrix
|
||||
@ -154,7 +154,7 @@ bool CreateMatrixElem(Matrix matrix, int ColPos, int RowPos);
|
||||
* @return an error code (int)
|
||||
*
|
||||
*/
|
||||
int SupprMatrixElem(Matrix matrix, int ColPos, int RowPos);
|
||||
int deleteMatrixElem(Matrix matrix, int ColPos, int RowPos);
|
||||
|
||||
/**
|
||||
* Delete or create the cell in the given matrix to fit the value
|
||||
@ -166,7 +166,7 @@ int SupprMatrixElem(Matrix matrix, int ColPos, int RowPos);
|
||||
* @return an error code (bool)
|
||||
*
|
||||
*/
|
||||
bool SetCellValue(Matrix matrix, int ColPos, int RowPos, bool value);
|
||||
bool setCellValue(Matrix matrix, int ColPos, int RowPos, bool value);
|
||||
|
||||
/**
|
||||
* Checks out the value of the cell in the given matrix
|
||||
@ -178,7 +178,7 @@ bool SetCellValue(Matrix matrix, int ColPos, int RowPos, bool value);
|
||||
* @return the value (bool)
|
||||
*
|
||||
*/
|
||||
bool GetCellValue(Matrix matrix, int ColPos, int RowPos);
|
||||
bool getCellValue(Matrix matrix, int ColPos, int RowPos);
|
||||
|
||||
/**
|
||||
* Set the number of columns and rows of the matrix and returns it
|
||||
@ -190,7 +190,7 @@ bool GetCellValue(Matrix matrix, int ColPos, int RowPos);
|
||||
* @return the matrix
|
||||
*
|
||||
*/
|
||||
Matrix SetMatrixDim(Matrix matrix,int nbCols,int nbRows);
|
||||
Matrix setMatrixDim(Matrix matrix,int nbCols,int nbRows);
|
||||
|
||||
/**
|
||||
* Basically print the Matrix in the standard output
|
||||
@ -364,7 +364,7 @@ bool bottomRule(Matrix m, int ColPos, int RowPos);
|
||||
*
|
||||
* @return bool the value of the cell got by the rule
|
||||
*/
|
||||
bool top_leftRule(Matrix m, int ColPos, int RowPos);
|
||||
bool topLeftRule(Matrix m, int ColPos, int RowPos);
|
||||
|
||||
/**
|
||||
* Get a cell with top_right rule
|
||||
@ -375,7 +375,7 @@ bool top_leftRule(Matrix m, int ColPos, int RowPos);
|
||||
*
|
||||
* @return bool the value of the cell got by the rule
|
||||
*/
|
||||
bool top_rightRule(Matrix m, int ColPos, int RowPos);
|
||||
bool topRightRule(Matrix m, int ColPos, int RowPos);
|
||||
|
||||
/**
|
||||
* Get a cell with bottom_left rule
|
||||
@ -386,7 +386,7 @@ bool top_rightRule(Matrix m, int ColPos, int RowPos);
|
||||
*
|
||||
* @return bool the value of the cell got by the rule
|
||||
*/
|
||||
bool bottom_leftRule(Matrix m, int ColPos, int RowPos);
|
||||
bool bottomLeftRule(Matrix m, int ColPos, int RowPos);
|
||||
|
||||
/**
|
||||
* Get a cell with bottom_right rule
|
||||
@ -397,7 +397,7 @@ bool bottom_leftRule(Matrix m, int ColPos, int RowPos);
|
||||
*
|
||||
* @return bool the value of the cell got by the rule
|
||||
*/
|
||||
bool bottom_rightRule(Matrix m, int ColPos, int RowPos);
|
||||
bool bottomRightRule(Matrix m, int ColPos, int RowPos);
|
||||
|
||||
/**
|
||||
* Get a list of bool from a given set of rules
|
||||
@ -410,7 +410,7 @@ bool bottom_rightRule(Matrix m, int ColPos, int RowPos);
|
||||
*
|
||||
* @return bool[] an array of bool
|
||||
*/
|
||||
bool * GetFromRules(Matrix m, int ColPos, int RowPos, int n, int rules[]);
|
||||
bool * getFromRules(Matrix m, int ColPos, int RowPos, int n, int rules[]);
|
||||
|
||||
/**
|
||||
* Allows you to use boolean operators between two matrices
|
||||
|
22
matrixmain.c
22
matrixmain.c
@ -37,31 +37,31 @@ int main(){
|
||||
Matrix m2;
|
||||
BooleanMatrix bmatrix;
|
||||
|
||||
useSDL = YesOrNo("Do you want to use SDL library for matrix display ?");
|
||||
useSDL = inputYesOrNo("Do you want to use SDL library for matrix display ?");
|
||||
printf("A random matrix will be generated\n");
|
||||
printf("Enter the number of columns of this matrix\n");
|
||||
col = SafeNumberInput(1, 30000);
|
||||
col = safeNumberInput(1, 30000);
|
||||
printf("Enter the number of rows of this matrix\n");
|
||||
row = SafeNumberInput(1, 30000);
|
||||
bmatrix = CreateBooleanMatrix(col, row);
|
||||
row = safeNumberInput(1, 30000);
|
||||
bmatrix = createBooleanMatrix(col, row);
|
||||
|
||||
bmatrix = RandomizeBooleanMatrix(bmatrix);
|
||||
bmatrix = randomizeBooleanMatrix(bmatrix);
|
||||
m1 = newMatrix(bmatrix);
|
||||
FreeBooleanMatrix(bmatrix);
|
||||
freeBooleanMatrix(bmatrix);
|
||||
|
||||
DisplayMatrixGUI(m1, useSDL);
|
||||
displayMatrixGUI(m1, useSDL);
|
||||
|
||||
while (cont){
|
||||
printf("What rule do you want to apply to this matrix ?\n");
|
||||
rule = SafeNumberInput(1, 481);
|
||||
rule = safeNumberInput(1, 481);
|
||||
printf("How many times do you want the rule to be applied ?\n");
|
||||
times = SafeNumberInput(1, 100000);
|
||||
times = safeNumberInput(1, 100000);
|
||||
m2 = applyRules(m1,rule,times);
|
||||
freeMatrix(m1);
|
||||
|
||||
DisplayMatrixGUI(m2, useSDL);
|
||||
displayMatrixGUI(m2, useSDL);
|
||||
|
||||
cont = YesOrNo("Do you want to apply other rules on this matrix ?");
|
||||
cont = inputYesOrNo("Do you want to apply other rules on this matrix ?");
|
||||
m1 = m2;
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@ Every function and data type are described in the documentation given with the p
|
||||
|
||||
# Algorithmic
|
||||
|
||||
The most interesting function are *GetCellValue* and *SetCellValue*. Those are the one we rely on the most. They are our way of dealing with our complex data structure allowing us to avoid to store false values. They are the functions that need the more computational power on the long run but are really useful due to their level of abstraction and their high level.
|
||||
The most interesting function are *getCellValue* and *setCellValue*. Those are the one we rely on the most. They are our way of dealing with our complex data structure allowing us to avoid to store false values. They are the functions that need the more computational power on the long run but are really useful due to their level of abstraction and their high level.
|
||||
|
||||
```C
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user