Text Adventures
A player types two words, a game answers. Split, case/when and a bit of state — the AI before the AI.
42 seconds · English captions included · 8.4 Mo
The 7 things you'll know how to do
Lesson 10: Text Adventures
Regarde la leçon (42 s) : avant ChatGPT, une IA s'appelait `split`. Un joueur tape des mots, un jeu répond — et tout tient dans trois idées.
The player's sentence
Écris `mots(commande)` : découpe la phrase du joueur en mots — `"prendre epee"` → `["prendre", "epee"]`. Un espace, deux mots : l'IA d'avant, c'était `split`.
The verb rules
Écris `verbe(commande)` : le PREMIER mot — c'est lui qui décide. `"prendre epee"` → `"prendre"` · `" ouvrir porte"` → `"ouvrir"` (les espaces en trop ne comptent pas).
The noun, or nothing
Écris `nom(commande)` : le DEUXIÈME mot, ou `nil` s'il n'y en a pas. `"prendre epee"` → `"epee"` · `"ouvrir grande porte"` → `"grande"` · `"marcher"` → `nil`. Une commande sans objet n'a pas de nom.
Recognize: two exact words
Écris `reconnait?(commande, verbe, nom_attendu)` : true seulement si la commande fait EXACTEMENT ces deux mots, dans l'ordre. `"epee prendre"` n'est pas `"prendre epee"` — le parser d'avant ChatGPT : deux mots, point final.
The guard's vocabulary
Écris `reponds(sujet)` : le garde parle par répliques prêtes — `"cle"` → `"Il désigne la serrure, sans un mot."` · `"bonjour"` → `"— Tu parles ? Ici, on répond par des gestes."` · tout autre sujet → `"— …"` (le silence : je ne comprends pas).
Lesson 10: OK
Sans aide : `reponse(etat, commande)` — l'ÉTAT + la commande exacte choisissent la réplique. `"prendre epee"` en `:debut` → `"L'épée est à toi."` · la même commande en `:fin` → `"Déjà prise."` · toute autre commande → `"— …"`.
📄 The cheat sheet
print it, stick it on your monitor, pretend it was your idea📄 Cheat sheet — Text Adventures (the parser before ChatGPT)
Before ChatGPT, an AI was called
split. The player types two words into the dark, the game answers — and it never understood a thing.
The history, in three lines
| Year | What happened | What it brought |
|---|---|---|
| 1976 | Colossal Cave Adventure | a world written in words |
| 1977 | Zork, 4 MIT students | the VERB + NOUN parser |
| 2020s | the LLMs | …and everyone forgot the parser ever existed |
A player types two words; the game answers. Nobody ever understood anything — and that's precisely why it worked.
The recipe: three ideas
"prendre epee".split # => ["prendre", "epee"] the sentence, cut
.split.first # => "prendre" the verb
.split[1] # => "epee" the noun (or nil)
Recognition: two exact words, in order
def reconnait?(commande, verbe, nom)
commande.split == [verbe, nom]
end
reconnait?("prendre epee", "prendre", "epee") # => true
reconnait?("epee prendre", "prendre", "epee") # => false — order matters
No guessed intent, no fuzzy matching: we compare strings — and we know how to say no. Saying no twenty times a row is the parser.
Dialogue: a case/when with a mandatory else
case sujet
when "cle" then "Il désigne la serrure, sans un mot."
when "bonjour" then "— Tu parles ? Ici, on répond par des gestes."
else "— …" # silence = "I don't understand"
end
Every known topic has its line; the else is mandatory — without it, the unknown answers
nil and your character "crashes" mid-sentence.
State: the same command, two replies
case [etat, commande] # compare the PAIR
when [:debut, "prendre epee"] then "L'épée est à toi."
when [:fin, "prendre epee"] then "Déjà prise."
else "— …"
end
The game's memory is nothing but a variable (:debut, :fin) that changes which lines are
true. The LLM improvises here; your case/when remembers.
Never say again
"you need an LLM to talk to the player"→ acase/whenand anelse"the parser must understand everything"→ two exact words; the rest is authorship"an AI is a model"→ in 1977, it wassplit.
SlopCourse — from slop to clean code.