MP 9: Infinite Maze
Overview
This MP is all about creating something as a course, together, that all of our work contributes to the final deliverable. You will develop a small but integral part of a complex software system. Unlike the other MPs, there is no “solution” to this MP – at this point, the deliverable does not exist and we are building it together.
- The infinite maze is one giant maze that grows forever.
- When you reach an “exit”, a new segment is generated to grow the maze.
- Every student contributes multiple backend microservices to the final system.
- All of the microservice runs simultaneously during the deployment of the system.
- You can view an early proof of concept right here.
MP Overview Session
An MP Overview session was held by Anna on Nov. 3 (Thursday) in SC-1304 at 05:00 pm. The slides can be found here.
Initial Files
In your CS 340 directory, merge the initial starting files with the following commands:
git fetch release
git merge release/mp9 -m "Merging initial files"
Part 1: Running the Provided Code
The middleware and frontend are completed and provided for you.
- Run the MP9 maze server by running
py -m flask run
/python3 -m flask run
. - You should see a maze with only
Err 503
tiles in the maze when connecting to the server with a web browser.
You will implement the backend microservices called “Maze Generators” or MGs. You MGs will be combined with other students’ MGs to create a global, course maze live in lecture on Nov. 10.
Part 2: Technical Requirement for MGs
For MP9, you are requred to create at least two MGs: at least one static MG and at least one dynamic MG.
-
A static MG returns the same maze every time.
-
A dynamic MG returns a different maze (with high probability) that has some design eleemnt to it. A completely random mess of random walls do not satisfy this requirement.
You must create each of these MGs inside of the mp9/MGs
folder as new, individual subfolders.
Generating a New Maze Tile: GET /generate
Your MG will respond to requests from the middleware via a response to the GET /generate
route. This route returns a JSON that must contain geom
that contains the geometry of the maze segment. The geometry is a array of strings, where each string is one row of the maze and each character is a single cell in the maze. For example:
{"geom": ["988088c", "1000004", "1000004", "0000000", "1000004", "1000004", "3220226"]}
is the geometry of an “empty” 7x7 segment.
Each character is a hex digit that encodes the walls of that cell.
- The most significant bit is
1
if there’s a wall on the north side of the cell, - The 2nd most significant bit is
1
if there’s a wall on the east side of the cell, - The 3rd most significant bit is
1
if there’s a wall on the south side of the cell, and - The least significant bit is
1
if there’s a wall on the west side of the cell
Connecting your MG to the Maze Server via PUT /addMG
To add an MG to the maze server, you must inform the maze server that your MG has launched. This is done via a PUT /addMG
request sent to the maze server. This request must include a JSON with keys 'name'
, 'url'
, and 'author'
. For example:
{ "name": "generator1",
"url": "http://127.0.0.1:34000/",
"author": "Your Name",
"weight": 1 }
-
The
name
value is displayed in the API’s list of available servers. -
The
url
value will be used the URL to communciate with your MG when sending aGET /generate
request. -
The
author
must be your name if you want to get credit for the MP! :) -
Finally, an optional
weight
key may be included to increase or decrease the probability of being randomly selected. The value must be a number greater than 0. If omitted, the weight will default to 1. -
The maze server API will respond with status code
400
if the JSON is malformed.
Hint: Configure your MG server to add itself to the API on startup, as manually sending the required JSON can be tedious. If the MG server has already been added, sending a second identical request to /addMG
will have no effect.
Testing
Once you have your static MG, test it! When your MG is connected, you will begin to see your tiles! :)
Make sure to complete both your static and dynamic MG. Your MGs must be creative and well-designed – a randomized hex string will not earn credit. Specifically unique designs will earn up to +5 EC.
Once you have a working local version, you’ll join the whole class for one giant maze!
Part 3: Running your MGs as part of Lecture on Nov. 10
In this part, you will connect your MGs to the server that is running the course-wide shared middleware.
Requirement 1: Deploy your MG on your CS 340 VM
You have a Virtual Machine (VM) provided for you as part of being in CS 340. This VM is similar to an AWS EC2 instance, except that it’s on our “private cloud” instead of the AWS “public cloud”.
-
EngrIt has created a “Power On / Reset VM” guide that details how to turn on your CS 340 VM.
-
The VM interface and your VM can only be accessed either on campus or via VPN. If you are not on campus, information about the UIUC VPN client is available here.
-
Once you have powered on the your box, you can SSH into it with your NetID and password.
-
You will likely need to install Python 3.9 on this machine since the default version of
python3
is only 3.6. This guide worked for me to install Python 3.9.. Once Python 3.9 is installed,python3.9 -m pip install flask
can be used to install flask and any other requirements.
Requirement 2: Connect with the Course-Wide Microservice
A course-wide infinite maze server will be hosted at http://fa22-cs340-adm.cs.illinois.edu:34000/
. You must configure your MGs to connect to this server when connecting to the course-wide microservice.
-
This machine can only be accessed either on campus or via VPN. If you are not on campus, information about the UIUC VPN client is available here.
-
I highly recommend that you use a
.env
or other config to easily switch between testing your microservice locally with localhost and connecting it to the course-wide microservice. -
Use Discord to check when this server is available.
Test Server Available
A test server is currently available at http://fa22-cs340-adm.cs.illinois.edu:34999/
. Make sure to connect to this test server to verify the back/forth communication with your maze. Make certain to test it. You will connect to a different server on Thursday.
Since your server must to communciate with a server not on your same physical machine, you cannot just use localhost
/127.0.0.1
. Instead, you must provide the address of your VM (http://fa22-cs340-###.cs.illinois.edu:#####
) whenc connecting to the course-wide server.
In addition, since your flask server must recieve connections from the course-wide server, you must have your flask app listen for all connections. Make sure your MG is running with --host=0.0.0.0
or configure your .env
to include FLASK_RUN_HOST="0.0.0.0"
Finally, there will be additional office hours to test your connection at 4:00pm-5:00pm on Wednesday. See the Canvas announcement for more details on the extra office horus!
Requirement 3: Particpating in the Infinite Maze
We will launch the course-wide infinite maze on Thursday, Nov. 10 in lecture!
-
Ensure your MGs are connected to the course-wide service before class, running on your VM.
-
EVERYONE must run their own MGs on their own VMs.
-
Be prepared to speak briefly about your MG. We will go through many MG and see your MGs you have developed and see the maze generated live before we deploy the full maze.
Submit
When you have completed your program, double-check that your server runs as expected by the specifications above. When you are ready, submit the code via the following git commands:
git add mp9/MGs
git commit -m "MP submission"
git push
You can verify your code was successfully submitted by viewing your git repo on your github account: https://github.com.