Problem 8 (200pts): report_progress
Implement report_progress
, which is called every time the user finishes typing a word. It takes a list of the words typed
, a list of the words in the prompt
, the user id
, and a send
function that is used to send a progress report to the multiplayer server. Note that there will never be more words in typed
than in prompt
.
Your progress is a ratio of the words in the prompt
that you have typed correctly, up to the first incorrect word, divided by the number of prompt
words. For example, this example has a progress of 0.25
:
report_progress(["Hello", "ths", "is"], ["Hello", "this", "is", "wrong"], ...)
Your report_progress
function should return this number. Before that, it should send a message to the multiplayer server that is a two-element dictionary containing the keys 'id'
and 'progress'
. The id
is passed into report_progress
from the GUI. The progress is the fraction you compute. Call send
on this dictionary to send it to the multiplayer server.
# Test your implementation
python ok -q 08