MathMai / README.md
Heterogeneity2025's picture
Upload 5 files
f4b7b59 verified
|
Raw
History Blame Contribute Delete
2.29 kB
---
title: Math Adventure
emoji: ๐Ÿงฎ
colorFrom: blue
colorTo: green
sdk: gradio
sdk_version: 6.17.3
app_file: app.py
pinned: false
license: mit
---
# ๐Ÿงฎ Math Adventure
A talking, tap-to-play math game for an advanced 5โ€“6 year old. Built with
[Gradio](https://gradio.app) (by Hugging Face). Each problem is **read aloud** by a
Hugging Face text-to-speech model (`facebook/mms-tts-eng`), so a child who can't yet
read fluently can still play. The difficulty **adapts automatically** โ€” it gets harder
as the child answers correctly and eases off after a couple of misses.
## What it covers
- **Addition & subtraction** โ€” within 5 โ†’ 10 โ†’ 20 โ†’ 100, plus missing-number problems (`7 + ? = 15`).
- **Counting & comparing** โ€” count objects, "which is bigger?", and missing numbers / skip-counting.
- **Simple multiplication** โ€” equal groups, then ร—2, ร—5, ร—10 and small times tables.
- **Shapes & patterns** โ€” name shapes, complete ABAB / AABB patterns, count sides.
## How it adapts
Held in game state: `level` (1โ€“10), `score`, and streaks.
- **Level up** after **3 correct in a row**.
- **Level down** after **2 wrong in a row** (it never punishes โ€” just eases off).
## Run it locally (Windows)
```powershell
py -m pip install -r requirements.txt
py app.py
```
Then open <http://localhost:7860>. The first launch downloads the TTS model (~145 MB) once.
## Run the logic tests
```powershell
py -m pip install pytest
py -m pytest test_game_logic.py
```
## Deploy to Hugging Face Spaces (free)
1. Create a free account at <https://huggingface.co>.
2. **New Space** โ†’ name it โ†’ **SDK: Gradio** โ†’ Hardware: **CPU basic (free)**.
3. Upload `app.py`, `game_logic.py`, `tts.py`, `requirements.txt`, and this `README.md`
(drag-and-drop in the Space's **Files** tab, or `git push` to the Space repo).
4. The Space builds automatically and gives you a public URL โ€” open it on a tablet and play.
## Files
| File | Purpose |
|------|---------|
| `app.py` | Gradio UI, game loop, audio, rewards. |
| `game_logic.py` | Problem generation + adaptive difficulty (pure Python, unit-tested). |
| `tts.py` | Hugging Face text-to-speech, with a silent fallback if audio can't load. |
| `test_game_logic.py` | Tests for problem generation and the difficulty engine. |