This is an archived copy of a previous semester's site.
Please see the current semester's site.
As decided by roughly a 75% majority vote1 after multiple rounds of elimination votes before that of those in class on March 28, our final project will be a distributed version of the Game of Life (GoL).
This page is a work-in-progress. Its content is correct, but incomplete, and will be added to as the project draws closer.
Each student will implement a GoL service responsible for part of the GoL board.
Course staff will implement a GoL aggregation and display middleware responsible for communicating with each service, assembling the full board, managing the passage of time, and displaying the board to clients (i.e. browsers).
The primary time-pass evolution of the GoL will run as follows:
The middleware will send each service a request meaning advance time one step based on these boundary conditions and tell me your new board.
Each service will reply with an ASCII representation of their board.
Your service will be stateful, with a web interface we provide to facilitate using several different configurations in the same run.
Color is provided, but its role in the simulation is left up to your creativity.
There is a user interface component where you can directly modify your board’s content.
We have a separate page describing how to get a minimal version of GoL implemented in just a few lines of code.
We have some initial files and automated tests:2 Last updated 2024-04-30 14:49 CDT; repeat these commands if you last ran them before then.
git fetch release
git merge release/project --allow-unrelated-histories -m "Merging initial files"
Your flask app will be stateful; in particular, it will have the following states:
Has not been told its board size by the middleware.
In this state, handle the following API endpoints:
Route | New state | Side effect |
---|---|---|
POST /inform | Waiting | PUT info about server to middleware |
POST /config | User Edit | initialize a GoL tile |
Accepts single-cell edits from a user interface we provide.
In this state, handle the following API endpoints:
Route | New state | Side effect |
---|---|---|
GET /stop | Waiting | discard the GoL tile |
GET /change/<x>/<y>/<c>/ | User Edit | change one cell in the tile |
POST /tick | Simulating | advance the simulation 1 tick |
Accepts time-step requests from the middleware.
In this state, handle the following API endpoints:
Route | New state | Side effect |
---|---|---|
GET /stop | Waiting | discard the GoL tile |
GET /pause | User Edit | (none) |
POST /tick | Simulating | advance the simulation 1 tick |
In all states, GET /ping responds with what state it is in, and tile contents if that is applicable for its state.
state
indicating which state (Waiting, User Edit, or Simualting) the server is in. If the state is not Waiting, also field tile
with the current cell contents of the tile as a string in the same format as POST /tick.
url
, containing a URL
Send a PUT request to that URL with JSON object body containing (at least) two entries: your NetID in the author
field and the base URL of your server in the url
field.
{
"author": "yournetid",
"url": "http://sp24-cs340-###.cs.illinois.edu:#####"
}
If you are develping on your own machine instead of your VM, use localhost
or 127.0.0.1
instead of your VM name, but don’t forget to change it back before the in-class project check-off.
width
and height
, giving the number of cells in this tile as positive integers.
Only valid in Waiting state; return a 409 Conflict status code if received in any other state.
Moves the server into the User Edit state.
Set cell of the tile to single-character cell code c
.
Accept the following cell codes:
0
through o
– fill the cell with that colorIf c
does not match one of those values or if is outside the bounds of your tile, return a 403 Forbidden status code.
Only valid in User Edit or Simulating state; return a 409 Conflict status code if received in any other state.
Moves the server into the Waiting state.
Only valid in Simulating state; return a 409 Conflict status code if received in any other state.
Moves the server into the User Edit.
A string containing one character for each cell surrounding the tile, clockwise from the top-left corner. This is the same format as MP9’s life_ring
function with characters like life_alphabet
. In particular,
' '
U+0020) means empty/kill this cell.
'#'
U+0023) means fill/birth this cell(with any color you want).
'"'
U+0022) means unspecified; we recommend handling this the same way you did in MP9, but if you’d rather treat this the same as a space character that is OK too.
'0'
U+0030) and Small O ('o'
U+006F) means full cell with a color, where the color is
rrggbb
,In Flask, the raw bytes of a request are in request.data
. You’ll probably want to decode that to a string using request.data.decode('ascii')
The build-in function chr(number)
converts a codepoint (like 0x51
) to its corresponding one-character string ('Q'
).
The build-in function ord(s)
converts a one-character string (like 'Q'
) to the codepoint of its character (0x51
).
'b'
The character 'b'
has code-point 98. Removing the 0x30 offset gives 50, or 0b110010. That means bright red (0b11, as high as 2 bits can go), no green (0b00, as low as 2 bits can go), and brightish blue (0b10, high but not as high as possible) for this color:
Suppose you have a 4-cells-wide 3-cells-tall tile.
0
ABCD
1
EFG
2
HIJK
3
LMN
The payload that will be sent from the middleware will be the 18-character string 0ABCD1EFG2KJIH3NML
life_alphabet
function.
Suppose you have a 4-cells-wide 3-cells-tall tile. You’d return a 15-character string:
Only valid in User Edit or Simulating state; return a 409 Conflict status code if received in any other state.
Moves the server into the Simulating state (if it was not already in that state).
Test your code with
python3 -m pytest
As of 2024-04-30 14:49 CDT4 If you downloaded the starter code before then, see Getting started for the commands to run to update the tests to the latest version., there are 10 tests covering most of the functionality of this project. However, they are cases that will arise in a live simulation that they do not test, so make sure to also run the local and VM tests listed below.
The automated tests only work with localhost URLs, not VM-specific URLs. This is needed because the VMs do not allow github to connect to them. After passing the tests, switch to the VM-specific URLs for the VM tests.
Submit your code with the usual commands:
git add -A
git commit -m "MP submission"
git push
Run the github pretest:
ActionTab
project pretest autograding
Run Workflowbutton (located on the blue bar)
Run Workflow
We install pytest
, flask
, and requests
on the autograder. If you want to install more packages, you can call pip
from inside your code as, e.g.
import subprocess
'pip', 'install', 'numpy'])
subprocess.run([import numpy as np
We provide a fully-functional middleware implementation and a web-based user interface for both the middleware and your tile server. To test your code, you’ll need to run both the middleware (python3 middleware.py
) and your tile server (python3 tileserver.py
) a the same time in different terminals, and then visit both in separate browser tabs or windows.
A basic test might run as follows:
http://localhost:34034
http://localhost:34034/addTS
).http://localhost:5000
OK(if it doesn’t, check the terminals to see what went wrong).
http://localhost:34034
Registered servers:.
Configure boardbutton.
http://localhost:5000
http://localhost:34034
1in the
Seconds between ticksfield and then click outside that field.
Various inputs on the middleware UI page change the tile server’s state (visible on the tile server pages):
Configure boardchanges tile servers from
Waitingto
User Input
Seconds between tickschanges servers from
User Inputto
Simulating
Pausebutton changes servers from
Simulatingto
User Input
Stopbutton changes servers to
Waiting
To conserve resources, updates to both UI pages are only made while those browser pages are focused. A running simulation does not stop when the page is out of focus, but the middleware page does not display the changes when it is not focused.
Additional tests:
still lifethat wraps the edges)
'"'
characters.Make sure your code works on your VM, with your VM’s URL in both your code and in the browser. This is how it will be tested in class on May 6. On May 6 you will not run your own middleware – the one we provided doesn’t scale to large numbers of users very well – but you will run your own tile servers. If your tile server works as designed, you should be able to run it once before class and leave it running throughout class: there should be no need to re-enter the VM and change things unless your code crashes.
Pass the VM tests
The day of the check-off, run your code on the vm with the following:
nohup python3 tileserver.py 1>>ts_output.log 2>&1 </dev/null &
echo $! >> ts_pid
The components of this pair of commands are:
nohup
– run a program such that it can keep running after you log outpython3 tileserver.py
– run your app. If your app needs a different command to run it, feel free to replace this accordingly1>>ts_output.log 2>&1
– append any output to the file ts_output.log
. You can view it by opening that file, cat
ing it, using tail -f ts_output.log
to watch for changes live, etc.</dev/null
– detach the program from user input, so that later things we type won’t go to it&
– run it in the backgroundecho $! >> ts_pid
store it’s process ID in a file. Thereafter if we want to stop it we’d run kill $(cat ts_pid)
Verify that you see the tile UI when visiting your VM’s URL and port in a browser
Attend class, where we will give you various middleware URLs to notify and tasks to perform. Some of those tasks will include
Draw a glider5 The getting started examples are gliders in the center of your tile; then we run. This will verify tile-to-tile hand-off works.
Draw something that shows off how you use color.
A test where there are roughly 2× tiles on the board as there are tile servers, to ensure '"'
borders and handled sanely.
Fill your tile with some involved shape (such as soup) and then we’ll make the middleware go faster and faster until tile servers start dropping out. We don’t have any particular speed requirement, but will give kudos to the fastest implementations and ask their authors to describe their approach.
Others to be revealed the day-of
The project is worth 15% of the overall grade. This will be divided as follows: