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.
In a terminal, run make view
Two ports will be displayed: 34009 and 5000
Open both ports in your browser.
On your local machine that means http://localhost:5000/ and http://localhost:34009/.
You’re welcome to test on your local machine if you’d like, but you should test on your VM at least once.
On your VM, that means http://fa24-cs340-###.cs.illinois.edu:5000 and http://fa24-cs340-###.cs.illinois.edu:34009.
In the Middleware service URL
field of the 5000 port page, enter the 34009 port URL.
You should see Connected
displayed below the middleware URL entry field.
On the 34009 port page, use the arrow keys (or WASD if you prefer that form of directionality) to navigate the maze.
You should start in an empty tile; the next tile should be your /static tile; after that you should see a series of /dynamic/F tiles.
(optional) With a friend, run all of your apps at once on the VM. Enter one of your 34009 URLs in all of your 5000 pages. All visit the same 34009 page; you should see a maze made of a random selection of all of your solutions.
On November 21, before class starts,
make background
On November 21, during class,