# FocusField

**See your attention as a magnetic field** — task pull vs distractors, with simplified MFA-style math. An educational browser demo for studying students; no LLM required.

**Author:** Cora Zeng  
**Event:** Prometheus July AI Challenge (education / interactive demo track)

---

## What it is

FocusField visualizes attention as a **magnetic field** over a 2D “study space.” You sit at the center; your task and distractors (phone, noise, chat, hunger) are sources with **field strength S** and **psychological distance r**. The demo shows:

- Which stimulus is **winning** your focus
- Combined **field strength at you**
- **Energy budget** overload (cognitive load)
- **Transfer risk** when a distractor crosses the MFA capture threshold

Drag distractors on the canvas to change distance. Use presets (*Deep work*, *Phone on desk*, *Exam hall*, *Overloaded*) to explore scenarios in under a minute.

Distinct from coding-agent tools like Cogram: this is **mechanism-first pedagogy**, not LLM memory.

---

## How the math works

FocusField implements a **lite version** of the Magnetic Field Model of Attention (MFA) proposed by Zeng (2026), framed alongside classic attention theory:

| Concept | Formula / rule | Source framing |
|--------|----------------|----------------|
| Field strength | `F_att(r) = S / (r² + ε)` | MFA field equation; ε avoids singularity at r→0 |
| Task as main source | `S_task` at small fixed offset from YOU | Posner (1980) spotlight — focal engagement |
| Peripheral capture | Transfer when `F_peripheral > S_main / r²` | MFA transfer criterion vs gradient/load (Lavie, 1995) |
| Energy budget | `Σ S_i · w_i ≤ E_total` (overload when demand exceeds budget) | Kahneman (1973) capacity; MFA energy constraint |
| Switching inertia | Exponential smoothing on focus weights (Lenz-style damp) | MFA Lenz’s-law mapping to task-switch cost (Monsell, 2003) |

### Variables in the UI

- **S_task / S_i** — stimulus salience (motivation × intensity)
- **r** — normalized distance on the canvas (drag to change)
- **E_total** — total attention energy available
- **Inertia** — how slowly focus can reallocate (higher = stickier)

### Softmax-style allocation

At each frame, raw attention weights are proportional to field strength at YOU. **Inertia** blends new weights with previous ones so focus doesn’t snap instantly — modeling switch cost without a separate penalty term.

---

## How to run

**Option A — local server (recommended):**

```bash
cd "d:\me\其他\性格\competitions\hackathon\Prometheus_July_AI_2026\focusfield"
python -m http.server 8765
```

Open http://localhost:8765

**Option B — open file directly:**

Double-click `index.html` (works in modern Chrome/Edge/Firefox; fonts load from Google Fonts if online).

No build step. Vanilla HTML + CSS + JS + Canvas 2D.

---

## Verify in 60 seconds

1. Open the demo → see **FocusField** hero + full-bleed field canvas.
2. Click **Phone on desk** → phone moves close; **Transfer risk** spikes; winner may flip to Phone.
3. Click **Deep work** → risk drops; task (gold) wins.
4. Drag **Noise** toward center → distance `r` shrinks; capture threshold crosses.
5. Lower **E_total** or click **Overloaded** → energy readout turns red.

---

## Prometheus / education track fit

- **Zero LLM** for core interaction — deterministic physics, immediate feedback
- **Teaches a real research model** (MFA) with citations, not a black-box “AI focus coach”
- **High school / college** audience: sliders, presets, visible formulas
- **Interactive science communication** — field lines, heatmap, capture labels

---

## Files

| File | Purpose |
|------|---------|
| `index.html` | Structure, hero, controls |
| `style.css` | Typography (Syne + Newsreader), atmospheric layout |
| `app.js` | MFA math, canvas render, presets, drag |
| `README.md` | This document |
| `SUBMISSION.md` | Devpost copy-paste blocks |

---

## References (framing)

- Zeng, Z. (2026). *Attention as a Magnetic Field* (MFA manuscript / arXiv preprint).
- Posner, M. I. (1980). Orienting of attention. *Quarterly Journal of Experimental Psychology*.
- Lavie, N. (1995). Perceptual load and selective attention. *Journal of Experimental Psychology: Human Perception and Performance*.
- Kahneman, D. (1973). *Attention and Effort*.
- Monsell, S. (2003). Task switching. *Trends in Cognitive Sciences*.

---

## License

Demo code for hackathon submission. MFA theory © Cora Zeng.
