A newer version of the Gradio SDK is available: 6.22.0
title: Analog Town
emoji: ๐ป
colorFrom: yellow
colorTo: green
sdk: gradio
app_file: app.py
pinned: false
license: mit
tags:
- track:wood
- achievement:offbrand
- achievement:fieldnotes
๐ป Analog Town
- Demo: https://youtu.be/y-Hc-Iu7YBs
- Post link: https://huggingface.co/blog/build-small-hackathon/analog-town
A shortwave simulator for fictional minds
You drop a piece of news into the town. The town changes. You tune the dial. The hidden reactions come through the static.
Analog Town is a whimsical "shortwave radio" interface for simulating how different fictional personas might internally process a piece of news, a story event, or a local proposal. It helps writers, tabletop RPG designers, and community organizers rehearse perspectives they might have missed.
โจ Key Features
- ๐๏ธ Create fictional towns with 3-6 agents, each with values, fears, hopes, and relationships
- ๐ข Broadcast events โ drop news into the town and watch how each persona reacts
- ๐ป Tune the radio dial โ slide through FM frequencies to intercept different minds
- ๐ Inspect structured traces โ see exactly what the model noticed, remembered, and felt
- ๐ฆ Export to Hugging Face Hub โ share your simulation traces as inspectable datasets
๐ Quick Start
# Clone and enter the project
cd analog-town
# Install dependencies
pip install -r requirements.txt
# Set your Hugging Face token
echo "HF_TOKEN=your_token_here" > .env
# Run the app
python app.py
Then open http://localhost:7860 in your browser.
๐ฎ How It Works
- Load a town โ Choose from preset towns or create your own
- Broadcast an event โ Enter a piece of news (e.g., "The old train station will become a luxury hotel")
- Tune the dial โ Slide the frequency knob to intercept different agents' thoughts
- Read the monologue โ Each agent produces a short internal monologue
- Inspect the trace โ See structured emotional state changes, value conflicts, and likely actions
- Export โ Download traces as JSON/JSONL or upload to HF Hub
๐๏ธ Architecture
analog-town/
โโโ app.py # Gradio UI application
โโโ schemas.py # Pydantic data models
โโโ prompts.py # Prompt templates
โโโ model_client.py # HF Inference API wrapper
โโโ simulator.py # State-transition engine
โโโ export_hub.py # Export & HF Hub upload
โโโ theme.py # Retro scanner CSS theme
โโโ test_cli.py # CLI test script
โโโ sample_towns/ # Preset town configurations
โ โโโ graybridge.json
โ โโโ neighborhood_council.json
โ โโโ port_whisper.json
โ โโโ brimstone_hollow.json
โ โโโ echo_summit.json
โ โโโ rustwood.json
โโโ avatars/ # 2D Pixel-Art Character Avatars
โ โโโ default.png
โ โโโ elder_man.png
โ โโโ elder_woman.png
โ โโโ young_man.png
โ โโโ young_woman.png
โ โโโ middle_man.png
โ โโโ middle_woman.png
โ โโโ soldier_man.png
โโโ static_ambient.wav # Atmospheric receiver static sound loop
โโโ outputs/ # Exported traces
โโโ requirements.txt
โโโ README.md
๐ง How the Simulation Works
Each agent runs through a typed state transition:
Previous Agent State + Broadcast Event โ Updated Agent State + Internal Monologue + Likely Actions
The model does NOT simply roleplay. It performs a controlled transition:
- Interpret the event from this agent's limited perspective
- Identify which memory or value is activated
- Compute emotional deltas (trust, anger, fear, hope, curiosity, social_energy)
- Update the state
- Produce a short internal monologue
- Produce likely private and public actions
- State uncertainty
All outputs are valid JSON with structured fields โ not free-form text.
๐จ The Radio Interface
The UI is designed to feel like an old shortwave radio or police scanner:
- Amber/green text on dark background
- Frequency dial from 87.0 to 108.0 FM
- Signal strength indicator โ stronger when tuned closer to an agent
- Static noise between stations
- Retro-futurist typography with IBM Plex Mono and Crimson Pro
โ๏ธ Safety & Ethics
Analog Town is a perspective-rehearsal tool. It does not predict real people.
- Use fictional, composite, or consent-based personas
- Do not use it to manipulate, profile, or target real individuals
- Exports automatically sanitize PII patterns
- All outputs include safety notes
๐ Export Format
Exports create a Hugging Face-compatible dataset:
analog-town-export/
โโโ town.json # Town configuration
โโโ broadcast_event.json # The broadcast event
โโโ agent_traces.jsonl # One JSON line per agent transition
โโโ README.md # Dataset card
โก Build Small Hackathon Compliance
Analog Town has been designed from the ground up to align perfectly with the guidelines of the Hugging Face Build Small Hackathon (Whimsical Track):
- Model Parameter Constraint (<32B): Built using the Hugging Face Inference Client configured with a strictly enforced fallback chain:
Qwen/Qwen2.5-7B-Instructas primary andQwen/Qwen2.5-14B-Instructas fallback. All models remain well below the 32B parameter hackathon limit. - Typed State Transition Engine: Instead of open-ended conversational roleplay, the simulation operates as a structured, deterministic state-transition engine utilizing strict Pydantic schemas, reducing model latency and compute overhead.
- Client-Side Optimization: Static receiver loop and audio volume-fading manager operate natively on the browser client, eliminating server-side rendering lag or unnecessary API roundtrips.
- Interactive Map and Custom Assets: Dynamic 2D isometric layouts with six distinct town presets and custom circular pixel-art avatars represent each mind as a signal node, bringing the retro shortwave theme to life.
๐ License
MIT
Analog Town is not a chatbot. It is a tiny social weather station for fictional worlds.