-
Notifications
You must be signed in to change notification settings - Fork 1
/
Maze.h
executable file
·68 lines (54 loc) · 1.23 KB
/
Maze.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
/*
* Maze.h
* MazeInC
*
* Copyright 2009-2018 Matthew T. Pandina. All rights reserved.
*
*/
#ifndef MAZE_H
#define MAZE_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdlib.h>
#include <stdbool.h>
#include "BitArray.h"
#include "DisjSets.h"
typedef enum _MazeCreateFlags {
mcfOutputMaze = 1,
mcfOutputSolution = 2,
mcfMultipleSolves = 4,
} MazeCreateFlags;
typedef struct _Wall {
uint32_t cell1;
uint32_t cell2;
} Wall;
typedef struct _Maze {
uint32_t totalPositions;
uint32_t totalWalls;
Wall *lottery;
uint8_t *neighborCount, *neighborCountCopy;
bool needsNeighborCountRefreshed;
uint32_t *dims;
uint32_t dims_length;
MazeCreateFlags createFlags;
DisjSetsRef sets;
BitArrayRef *halls;
BitArrayRef *solution;
// Trivia
uint32_t solutionLength;
uint32_t start;
uint32_t end;
// The number of cores to use
uint32_t cores;
} Maze;
typedef Maze *MazeRef;
MazeRef Maze_create(uint32_t *dims, uint32_t length, MazeCreateFlags flags);
void Maze_delete(MazeRef m);
void Maze_setCores(MazeRef m, uint32_t cores);
void Maze_generate(MazeRef m);
void Maze_solve(MazeRef m, uint32_t start, uint32_t end);
#ifdef __cplusplus
}
#endif
#endif // DISJSETS_H