Track project: Command brain
Give Vault Breaker a smart parser that understands commands it was never told about.
Code runs right here in your browser. Nothing to install.
Mission briefing
Commands that share the most words with an example get its verb.
Players type things like "walk to the north door" or "grab that keycard", but your parser only understands go and take. In this project you build a tiny text classifier that learns from examples which verb a command means.
It uses nearest neighbours with words instead of numbers: two commands are similar if they share words. The Jaccard similarity is the number of shared words divided by the number of different words in both: len(a & b) / len(a | b).
Capture the flag
+10 XP"take the key" and "take the torch" share 2 words out of 4 different words. What is their Jaccard similarity? (a decimal)
Create a free account to start this lab
Sign in to answer the flag question. Your progress, XP and code are saved to your account. No card needed.
Build the command brain
+20 XPUsing the EXAMPLES training data:
- write
words(text)that returns a set of lowercase words with punctuation removed - write
similarity(a, b)that returns the Jaccard similarity of two word sets - write
classify(command)that returns the verb of the most similar example, or"unknown"if the best similarity is 0 - test it on the
TESTSlist, printingwalk to the north door -> goand so on, then the accuracy asAccuracy: 5/6or better
Create a free account to start this lab
Sign in to do this homework and have it checked. Your progress, XP and code are saved to your account. No card needed.