Overview

Demo of project, showing typing speed & accuracy.

TypeRacer.com is a now-classic website (from way back in 2008) where players compete in small groups to type a quotation as fast as possible. This Typing Speed project implements a game similar to Type Racer, starting with typing speed and accuracy measurements, then adding nifty features like multiplayer support and autocorrect using string edit distance.

Trying it out

Our staff solution to the project can be accessed at cats.cs61a.org. Although the GUI itself is provided to students, the backend (including calculations for speed and accuracy, autocorrecting, and communication with the multiplayer server) is almost entirely implemented by students.

The specification distributed to students links to all starter files.

Meta Information

Summary

Typing races are surprisingly fun, but also have the practical benefit of improving typing speed and accuracy. Computing edit distance for the autocorrect feature is a motivating example of tree recursion. While the project is designed for a Python-based course, the open-source React-based web GUI is also easy to read and extend. There are lots of opportunities to extend the Python portion of the project, for example with post-game analysis of how fast each word was typed or by adding more sophisticated autocorrect suggestions.

Audience Intermediate CS1
Topics Built-in Python container types (lists, strings, and dictionaries), list comprehensions, higher-order functions, iteration, and tree recursion. This project does not involve any user-defined classes.
Difficulty

There are two hard questions out of nine, giving students a substantial challenge along with plenty of early wins. The project is heavily scaffolded, and students are guided through the program design and decomposition. Almost all of our students completed the project with full credit, although some required substantial one-on-one help.

Strengths

Fun & Concrete - As students complete each part of this project, new functionality is added to their typing speed game. The game provides visual feedback that lets students directly interact with their code.

Full test suite - The project is distributed with a full suite of tests that includes fuzz tests for most questions to verify the correctness of student programs.

Weaknesses

Linear Completion - For the most part, problems cannot be completed out of order, and so getting stuck on one problem prevents students from making further progress.

Highly structured - As the project is written, students are not given the freedom to design their own program structure. Instead, the structure is provided, and students fill in the logic of each modular component.

Edit distance is widely known - It is easy to find implementations for the edit distance algorithm online.

Dependencies

The Python component uses only the Python 3 standard library. The web GUI is a static site that is distributed with all of its dependencies.

Variants

Students can improve their autocorrect suggestions by:

  • Improving efficiency through memoization.
  • Taking into account physical distance on the keyboard to determine what the intended word was (e.g. someone who typed "mpre" probably meant to type "more", not "mare").
  • Taking into account common misspellings or context.

This project also provides an opportunity to introduce miscellaneous string-processing questions, such as

  • Translating the source text to Pig Latin.
  • Analyzing what types of words a user commonly misspells.
  • Implementing autocomplete, which might make this project suitable for a CS2 class.

Feedback

Some sample positive feedback, shamelessly cherry-picked from our student survey:

[I liked] the fact that the amount of code provided was minimal and basically we were responsible to implement all functions. This project was a big step towards understanding of how to write code and functions step by step to create a project.
I have played type racer before and it is a lot of fun but never thought about how it works! So doing this project was really interesting because I could relate to it and wanted to recreate it myself.
I really enjoyed that we were making something that we encounter everyday- autocorrect. I finally understood recursion after this project too so it was interesting to implement for this project.
I like how it mimics something that many of us can relate to, a game that we can all easily visualize. Also because it is something that we have all played before, there is more of an incentive or more so curiosity to complete the project.
I liked that this project helps me visualize what my phone does when it does autocorrect. That is cool!
pretty much all of the problems were interesting and fun to solve