analog-town / README.md
thangvip's picture
Update README.md
4bd5014 verified
|
Raw
History Blame Contribute Delete
6.3 kB

A newer version of the Gradio SDK is available: 6.22.0

Upgrade
metadata
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

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

  1. Load a town โ€” Choose from preset towns or create your own
  2. Broadcast an event โ€” Enter a piece of news (e.g., "The old train station will become a luxury hotel")
  3. Tune the dial โ€” Slide the frequency knob to intercept different agents' thoughts
  4. Read the monologue โ€” Each agent produces a short internal monologue
  5. Inspect the trace โ€” See structured emotional state changes, value conflicts, and likely actions
  6. 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:

  1. Interpret the event from this agent's limited perspective
  2. Identify which memory or value is activated
  3. Compute emotional deltas (trust, anger, fear, hope, curiosity, social_energy)
  4. Update the state
  5. Produce a short internal monologue
  6. Produce likely private and public actions
  7. 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-Instruct as primary and Qwen/Qwen2.5-14B-Instruct as 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.