-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathheader.h
80 lines (51 loc) · 3.63 KB
/
header.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
// macros
#define ROWMAX 100 // maximum lenght of SVG file row
#define COLCOUNT 10 // SVG file max columns
#define NAMELEN 30 // max length for string inputs
#define MAZEMIN 5 // min size for a maze
#define MAZEMAX 100000 // max size for a maze
#define BILLION 1000000000.0 // for keeping time on generation algorithms
#define MENUOPTION 10 // standard length for menu options
#define COLORCOUNT 14 // currently supported bitmap colors
#define BMPTARGETSIZE 3000 // target bitmap width in pixels
enum algoArr{generated, deadend, recursive, breath_first, final_maze}; // the same order the mazes are in the struct array
enum bitmap_mode{regular, secret, insanity}; // for BMP file creation color menu
enum element_type{wall, path, rec_path, bfs_path, crossover}; // element type, used in BMP and SVG file creation
// holding mazes
typedef struct data{ // keeping an individual maze
short **maze; // maze matrix
}data_t;
typedef struct dataArr{ // array of mazes for different algos
short exits[4]; // mark entrance and exit coordinates
int size; // maze size
int algoCount; // the number of solving algorithms + 2 for generation and final solution
data_t *algo; // array of maze matrixes
}maze_t;
// memory management
void freeMemory(maze_t *M); // free memory of maze_t
void feedMemory(maze_t *M); // give memory for maze_t according to M->size
// maze generation
void Ellermaze(int size, short **maze); // maze generation using Eller's algorithm
void treemaze(int size, short **maze, short algo, short algoloop); // treealgorithm
void addBorders(short **cells, int size); // adds borders for maze generation
// maze solving
void findExits(int size, short **maze, short exits[4]); // finding the entrance and exit
double deadEnd(int size, short **maze, short exits[4]); // using the dead end filler algorithm
double recursion(int size, short **raw, short **sol, short exits[4]); // recursive backtracker
double bfs(int size, short **raw, short **sol, short exits[4]); // breath first search
// managing files
enum file_complexity{automatic, manual, ask_user}; // int complexity in manageFiles
enum file_mode{read, write}; // int mode in manageFiles
enum file_type{txt_file, svg_file, bmp_file}; // the int filetype in manageFiles,
//makes for easier function calling
int manageFiles(int mode, int filetype, int complexity, int mazetype, maze_t *M); // central hub for file management
FILE *getFilename(int mode, int filetype, int complexity, int mazetype);
void mazeReset(maze_t *M); // resetting a solved maze
int sizeCheck(int size); // to check if maze size is allowed
int writeSVG(FILE *svg, maze_t *M, int mazetype); // making the SVG file
int readSVG(FILE *svg, maze_t *M); // reading SVG files
int makeBMP(FILE *f, int mode, int mazetype, maze_t *M); // experimental, BMP file creation