A simple REST API that generates random mazes.
$ curl 'http://localhost:3000/api/v1/maze/random/<rows>/<columns>/[algorithm]'
Where the parameters are:
rows
- The number or rows in the generated mazecolumns
- The number or columns in the generated mazealgorithm
- [Optional] The algorithm that is used to generate the maze. Currently only supportsRDFS
(Default:RDFS
)
The response for this endpoint is:
{
"rows": "2",
"columns": "2",
"algorithm": "RDFS",
"data": {
"structure": [
[
{
"useLeftWall": true,
"useRightWall": false,
"useFrontWall": true,
"useBackWall": true
},
{
"useLeftWall": false,
"useRightWall": true,
"useFrontWall": false,
"useBackWall": true
}
],
[
{
"useLeftWall": true,
"useRightWall": false,
"useFrontWall": true,
"useBackWall": true
},
{
"useLeftWall": false,
"useRightWall": true,
"useFrontWall": true,
"useBackWall": false
}
]
]
}
}
Where data.structure
is a 2 dimentional array of the size rows
xcolumns
where each cell describes which walls to use to build the maze.
# development
$ npm run start
# watch mode
$ npm run start:dev
# production mode
$ npm run start:prod
# e2e tests
$ npm run test:e2e