blob: b9f846a0cff906530693ade29072453eca929dd5 (
plain)
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
|
h1. Maze
Maze generator and A* path finder.
It's horrible, and needs refactoring, but it works.
h2. Server/client
There is a ruby/sinatra server, which does all of the hard work, and exposes an api.
There is a JS/p5.js front end to it, which only does UI.
h2. API
- GET /api/v0.1/maze := Get the MML definition of the maze
- POST /api/v0.1/maze := Generate a new maze (returns MML)
- GET /api/v0.1/path := Get the PML definition of the path, if any
- GET /api/v0.1/path/valid := Returns the work "true" or "false" if a path has been found
- POST /api/v0.1/path := Generate a new path (returns nothing)
h2. Maze Markup Language / Path Markup Language
h3. MML
MML describes the maze in the following format:
bc. 40 30
10 11
22 13
1 3 4 5
30 23 2 2
[...]
* Line 1 is the width and height of the maze
* Line 2 is the starting x and y coordinates
* Line 3 is the target x and y coordinates
* Line 4 and beyond are untraversable "blocks":
** The first two numbers are the anchor x and y coordinates of the block
** The second two numbers are the width and height of the block
* All other nodes are considered traversable
* There is no diagonal path between two untraversable nodes touching at a corner
h3. PML
PML describes the path in the following format:
bc. 11 12
12 13
13 13
14 13
15 13
[...]
* Each line contains the x and y coordinates of the next step in the path
* The start and target do not appear in the path
|