Skip to content

Commit

Permalink
Testing version: Commented printfs to test
Browse files Browse the repository at this point in the history
  • Loading branch information
elvishribeiro committed Dec 11, 2019
1 parent e0f8057 commit aee16c5
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 56 deletions.
38 changes: 0 additions & 38 deletions fileHandler.c

This file was deleted.

33 changes: 17 additions & 16 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,55 +22,56 @@ int main (int argc, char **argv) {

readFile(argv[1], &conf, &eco);

int matrix_size = conf.L*conf.C*sizeof(object_t);

next_eco = allocateMatrix(conf.L, conf.C);
deepcopy(next_eco, eco, conf.L, conf.C);

system("clear");
//system("clear");
printf("-------GEN:%2d-------\n", 0);
printMatrix (eco, conf.L, conf.C, conf);

//usleep(500000);
getchar();
system("clear");
printf("-------GEN:%2d-------\n", 1);
//getchar();
//system("clear");
//printf("-------GEN:%2d-------\n", 1);

for (unsigned int t = 1; t <= conf.N_GEN; t++){
conf.GEN++;
// COELHO
for (unsigned int i = 0; i < conf.L; i++){
for (unsigned int j = 0; j < conf.C; j++){
p = (coord_t){.x = i, .y = j};
if (eco[i][j].type == RABBIT){
p = (coord_t){.x = i, .y = j};
rabbit_rules (eco, next_eco, conf, p);
}
}
}
conflict(next_eco, conf, RABBIT);
deepcopy(eco, next_eco, conf.L, conf.C);
printMatrix (eco, conf.L, conf.C, conf);

//printMatrix (eco, conf.L, conf.C, conf);
//usleep(500000);
getchar();
system("clear");
printf("-------GEN:%2d-------\n", t);
//getchar();
//system("clear");
//printf("-------GEN:%2d-------\n", t);
for (unsigned int i = 0; i < conf.L; i++){
for (unsigned int j = 0; j < conf.C; j++){
p = (coord_t){.x = i, .y = j};
if (eco[i][j].type == FOX){
p = (coord_t){.x = i, .y = j};
fox_rules (eco, next_eco, conf, p);
}
}
}
conflict(next_eco, conf, FOX);
deepcopy(eco, next_eco, conf.L, conf.C);

printMatrix (eco, conf.L, conf.C, conf);
//printMatrix (eco, conf.L, conf.C, conf);
//usleep(500000);
getchar();
system("clear");
printf("-------GEN:%2d-------\n", t+1);
//getchar();
//system("clear");
//printf("-------GEN:%2d-------\n", t+1);
}

printf("-------GEN:%2d-------\n", conf.GEN);
printMatrix (eco, conf.L, conf.C, conf);

return 0;
Expand Down
4 changes: 2 additions & 2 deletions rules.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ void fox_rules (object_t **eco, object_t **next_eco, config_t conf, coord_t p) {
/* Movement */
if (!predation(eco, next_eco, conf, p)) {
eco[p.x][p.y].animal.hunger++;
if(eco[p.x][p.y].animal.hunger >= conf.GEN_COMIDA_RAPOSAS){
next_eco[p.x][p.y].type = EMPTY;
if(eco[p.x][p.y].animal.hunger >= conf.GEN_COMIDA_RAPOSAS){ //death
clear_position(&(next_eco[p.x][p.y]));
}
else
fox_move(eco, next_eco, conf, p);
Expand Down

0 comments on commit aee16c5

Please sign in to comment.