Play room is designed around maximal permissiveness: always try to do something meaningful with whatever the child types. This document explains how the evaluator thinks about expressions.
Be like a kind teacher, not a strict compiler. If a 5-year-old types something, find a way to make it work. Never show errors. Always produce a visual result when possible.
Standard arithmetic with operator precedence preserved:
2 + 2 → 4 (with dot visualization: ••••)
3 * 4 + 2 → 14 (multiplication before addition)
(2 + 3) * 4 → 20 (parentheses override precedence)
10 / 2 → 5
Words become emojis. Supports multiplication and addition:
cat → 🐱
3 cats → 🐱🐱🐱
cat * 5 → 5 🐱
🐱🐱🐱🐱🐱
cats → 🐱🐱 (bare plural = 2)
cat + dog → 🐱 🐶 (space between different types)
cat + cat → 🐱🐱 (no space, same type)
Colors mix like paint (subtractive mixing):
red + blue → purple (big swatch display)
red + yellow → orange
3 red + 2 blue → weighted mix toward red
Emojis, colors, numbers, and text can all combine:
apple + red + green → Line 1: 🍎 [red] [green] (inputs)
Line 2: 🍎 [mixed] (result)
3 + 4 + 2 bananas → 9 bananas
🍌🍌🍌🍌🍌🍌🍌🍌🍌
gibberish + blue → gibberish [blue swatch]
When numbers appear before emojis in a + expression, they accumulate and attach:
3 + 4 + 2 bananas → 9 bananas (3+4+2=9, then attach to bananas)
5 + 2 cats + 3 dogs → 7 cats + 3 dogs (5+2=7 cats, 3 dogs separate)
Math operators follow standard precedence, even with emojis:
3 * 4 + 2 dogs → 14 dogs (3*4=12, +2=14)
2 + 3 * 4 cats → 14 cats (3*4=12, +2=14)
(2 + 3) * 4 cats → 20 cats (parentheses first)
When computation happens, show the count to help kids understand:
3 * 4 + 2 dogs → 14 🐶
🐶🐶🐶🐶🐶🐶🐶🐶🐶🐶🐶🐶🐶🐶
12 * 3 cats → 36 🐱
🐱🐱🐱🐱... (36 cats)
(cat * 3) + 2 → 5 🐱
🐱🐱🐱🐱🐱
(2 * 3) cats → 6 🐱
🐱🐱🐱🐱🐱🐱
Parentheses imply computation, so they always show labels:
(2 + 2) cats → 4 🐱
🐱🐱🐱🐱
what is (3 * 2) dogs → what is 6 🐶
what is 🐶🐶🐶🐶🐶🐶
But simple expressions don't need labels:
3 cats → 🐱🐱🐱 (no label, obvious)
6 cats → 🐱🐱🐱🐱🐱🐱 (no label, no computation)
cat → 🐱
Visual clarity for kids:
cat + dog → 🐱 🐶 (space between)
2 cats + 3 dogs → 🐱🐱 🐶🐶🐶 (space between groups)
3 cats → 🐱🐱🐱 (no space, same type)
All colors in an expression mix together:
red + cat + blue → Cat appears, colors mix to purple
apple + red + green → Apple appears, colors mix
Text that isn't recognized still appears, with valid terms processed:
my name is tavi apple → my name is tavi 🍎
gibberish + blue → gibberish [blue swatch]
When English text precedes an expression, the text is preserved:
what is 2 + 3 → what is 5
what is •••••
I have 5 apples → I have 🍎🍎🍎🍎🍎
I have 2 + 3 apples → I have 5 🍎
I have 🍎🍎🍎🍎🍎
what is red + blue → what is [color result]
show me 3 cats → show me 🐱🐱🐱
The prefix must be plain English text (no emojis, numbers, or operators). This allows natural questions like "what is 2 + 2" to work intuitively.
All of these mean the same thing:
*(asterisk)x(letter x between numbers/words)times(word)
3 * cat → 🐱🐱🐱
3 x cat → 🐱🐱🐱
3 times cat → 🐱🐱🐱
cat times 3 → 🐱🐱🐱
5 x 2 cats → 10 cats (5*2=10)
Autocomplete helps kids discover words:
- Triggers at 2+ characters (e.g., "ca" suggests "cat")
- Common 2-letter words are excluded to prevent unwanted completions
- Excluded: am, an, as, at, be, by, do, go, he, if, in, is, it, me, my, no, of, on, or, so, to, up, us, we, hi, oh, ok
- Space accepts the current suggestion
- Exact matches don't show suggestions (typing "cat" doesn't suggest "cat")
All output lines get the → prefix for visual consistency.
When colors mix with emojis, show inputs then result:
Ask: apple + red + green
→ 🍎 [red] [green] (what you typed)
→ 🍎 [mixed] (what you get)
Small numbers (1-999) show dots below:
Ask: 5
→ 5
→ •••••
-
No error messages. A 4-year-old shouldn't see "syntax error". If they type something, show them something.
-
Intuitive over correct.
3 + 4 + 2 bananasbecoming9 bananasis what a child expects, even if it's not mathematically rigorous. -
Discovery through play. Kids learn what works by trying things. Permissive evaluation rewards experimentation.
-
Visual feedback always. Even "gibberish + blue" shows the blue. There's always something to see.
Kids will eventually learn real math. Better to teach them correctly from the start. 3 * 4 + 2 = 14, not 18.
When the result isn't obvious from the input, show the count. 3 * 4 + 2 dogs needs the "14 🐶" label because a child can't easily compute that. But 3 cats doesn't need a label because it's visually obvious.
Parentheses always trigger labels because they imply computation happened, even if the final expression looks simple. (2 * 3) cats becomes 6 cats after paren evaluation, but we show 6 🐱 as a label because the child typed a computation.
🐱🐶 is harder to parse visually than 🐱 🐶. Spaces help kids see "this is a cat AND a dog" rather than "this is one thing".
Add ! anywhere in your input to hear it spoken aloud using Piper TTS. The ! is stripped before display and evaluation.
| Method | Example | Notes |
|---|---|---|
! anywhere |
cat!, !2+2, ca!t |
Most intuitive for kids |
say or talk prefix |
say cat, talk 2+2 |
Alternative syntax |
| Enter on empty | (press Enter after a result) | "Say it again" |
- Say minimal text. Don't pronounce emoji symbols or color boxes.
- For computation: Say "input equals result"
- For simple lookups: Just say the word
cat! → shows 🐱, says "cat"
3 cats! → shows 🐱🐱🐱, says "3 cats"
cat * 3! → shows result, says "cat times 3 equals 3 cats"
2 + 3 apples! → says "2 plus 3 apples equals 5 apples"
red + blue! → says "red plus blue equals purple"
what is 2 + 3! → says "what is 2 plus 3 equals 5"
After any result, pressing Enter with empty input repeats the last spoken result. This is the "what did it say?" feature for kids who want to hear it again.
*→ "times"+→ "plus"-→ "minus"/→ "divided by"- Parentheses are removed
Numbers attach to the next term (color or emoji). They accumulate until they hit something.
2 + 3 yellow → 5 yellows (2+3=5 attaches to yellow)
2 + red → 3 reds (2+1=3)
3 + 4 + 2 bananas → 9 bananas (3+4+2=9 attaches to bananas)
2 + red + 3 cats → 3 reds + 3 cats (2→red, 3→cats)
Colors still mix together regardless of where they appear in the expression.
Some words are both colors and emojis (e.g., "orange", "peach", "rose"). The behavior is context-sensitive:
orange → 🍊 (fruit emoji)
peach → 🍑 (fruit emoji)
3 orange → 🍊🍊🍊 (emoji multiplication)
orange + blue → color mix (greenish-brown)
2 + 3 orange → 5 oranges for color mixing
When typing "ora", autocomplete shows overlapping words grouped together:
orange 🍊 ██
The emoji appears first, then the color swatch. This helps kids see both options exist for words like "orange", "peach", and "rose".
The evaluator tries methods in order:
- Parentheses (recursive evaluation)
- Text with expression (e.g., "what is 2 + 3")
- Plus expressions (with color mixing, emoji handling)
- Multiplication expressions
- Pure math
- Text substitution (emoji replacement in sentences)
Each method can "pass through" to the next if it doesn't fully handle the input. This layered approach allows complex expressions to be evaluated piece by piece.
Math operators are defined centrally in SimpleEvaluator:
MATH_SYMBOLS:{'+', '-', '*', '/', '×', '÷', '−'}WORD_TO_SYMBOL:{'times': '*', 'plus': '+', 'minus': '-', 'x': '*'}PLUS_PATTERN: regex for detecting + or "plus"MATH_CHARS_PATTERN: regex for valid math expression characters
💜