Problem 10 (200pts): fastest_words
Implement fastest_words
, which returns which words each player typed fastest. This function is called once both players have finished typing. It takes in a game
.
The game
argument is a game
data abstraction, like the one returned in Problem 9. You can access words in the game
with selectors word_at
, which takes in a game
and the word_index
(an integer). You can access the time it took any player to type any word using the time
function provided in cats.py
.
The fastest_words
function returns a list of lists of words, one list for each player, and within each list the words they typed the fastest. In the case of a tie, consider the earliest player in the list (the smallest player index) to be the one who typed it the fastest.
Be sure to use the accessor functions for the game
data abstraction, rather than assuming a particular data format.
Congratulations! Now you can play against other students in the course. Set enable_multiplayer
to True near the bottom of cats.py and type swiftly!
python gui.py
You can open multitabs in a brower to visit your game and test your implementation alone. Or you can call your friend up to compete with you :D
It seems that your
gui.py
is running in your own brower, then how could they communicate with each other? In fact,gui.py
s do not know each other, they are just a client which will connect tocats.cs61a.org
's server program. That program will handle all clients requests and response back.
Congratulations, you have reached the end of your second project! If you haven't already, relax and enjoy a few games of Cats with a friend.
# Test your implementation
python ok -q 10