#include #include #include #include "../include/binaryTree.h" #include "../include/labyrinth.h" Labyrinth* binaryTree_r(int n, int m, bool show); Labyrinth* binaryTree(int n, int m){ return binaryTree_r(n, m, false); } Labyrinth* binaryTreeShow(int n, int m){ return binaryTree_r(n, m, true); } // creates a labyrinth using the binaryTree algorithm Labyrinth* binaryTree_r(int n, int m, bool show){ int i, j, tmp; Labyrinth* labyrinth = newLabyrinth(n, m); labyrinth->at[0][0].east = 1; labyrinth->at[0][0].south = 1; if(show){ labyrinth->at[0][0].color = ORANGE; printLab(labyrinth); labyrinth->at[0][0].color = WHITE; } for(i=1; iat[i-1][0].south = 1; if(show){ labyrinth->at[i-1][0].color = ORANGE; printLab(labyrinth); labyrinth->at[i-1][0].color = WHITE; } } for(j=1; jat[0][j-1].east = 1; if(show){ labyrinth->at[0][j-1].color = ORANGE; printLab(labyrinth); labyrinth->at[0][j-1].color = WHITE; } } for(i=1; iat[i][j].color = ORANGE; printLab(labyrinth); labyrinth->at[i][j].color = WHITE; } tmp = rand()%2; if(tmp) labyrinth->at[i-1][j].south = 1; else labyrinth->at[i][j-1].east = 1; } } resetLabyrinth(labyrinth); return labyrinth; }