In this MP, you will create a web service that works together with other students’ web services to create a collaborative distributed infinite maze.
The maze is organized around tiles
or segments
, 7×7 mini-mazes. Each tile has (up to) four exits, one on the center of each of its four sides. The infinite maze is generated by requesting new tiles as soon as a given tile is exited. We have an early proof of concept which doesn’t use servers, instead re-using the same tile every time, which we hope will help the idea make more sense.
Some of the points in this MP are handled by automated tests. The remaining points are handled by your code correctly interacting with others’ code in an in-class demo.
mazeview.py
)Initial files are available in mp9.zip, including two files you’ll edit:
mazegen.py
is an aiohttp
web service.mazelib.py
is an optional second file where we recommend you put your maze generation code.The Makefile
has a variety of targets:
make run
starts mazegen.py
on port 5000make view
starts both mazegen.py
on port 5000 and mazeview.py
on port 34009make test
uses pytest to check your code’s correctnessmake background
starts mazegen.py
on port 5000 as a daemon process; make stop
kills that daemon.In mazegen.py
, implement a web service with the following properties:
GET /static
returns the same 7×7 maze tile with 4 exists each time it is invoked. We recommend hand-crafting a maze
that you think looks cool.
Mazes tiles are returned as JSON arrays of seven seven-character strings; each character is a hexadecimal digit indicating which walls of that cell are present.
A hexadecimal digit has four bits.
An empty cell with four exists is encoded as
[ "988088c"
, "1000004"
, "1000004"
, "0000000"
, "1000004"
, "1000004"
, "3220226"
]
The walls must be two-sided; for example, if one cell has a wall on it’s right then the cell to the right of it must have a wall on its left.
GET /dynamic/0
, GET /dynamic/1
, …, GET /dynamic/F
return random 7×7 mazes with the specified set of exits.
These are in the same JSON format as static maze tiles.
Its exists are indicated with the same hexadecimal code as cells: 0 has all four exits open, 1 has the left exit closed but the other three open, and so on.
The maze must be solvable; that is, there must be a path from each open exit to each other open exit.
We have a separate page on maze generation.
If you run your mazegen.py
and visit it in the browser, you will see a visualization of mazes and a field for registering your maze generator with a middleware.
If you run python3 -m pytest
you’ll see our estimation of the correctness of your solution.
Automated tests will also be run when you submit your code on the secure upload site.
On November 21 we will run all maze generators as part of an in-lecture check-off for the other half of your MP9 grade.
You can pre-test that your code works by using make view
to run our example middleware and make sure you can register your maze generator with the middle ware and explore the resulting maze.
On November 21, your maze generator must be running on your course virtual machine. The make background
target is provided to make that easier to achieve.