Skip to content

Eva-E1/BRING

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

17 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŒŸ BRING v2 โ€“ Building Rich Interactive Narrative Games

BRING v2 is a productionโ€‘ready, AIโ€‘powered platform for building, exploring, and living in persistent fantasy worlds.
It combines generative world construction, graphโ€‘based knowledge management, deterministic probability systems, intelligent narrative orchestration, and immersive roleplay โ€“ all driven by large language models (LLMs) and FAISSโ€‘accelerated memory.

โ€œFrom a single prompt to a living, breathing world โ€“ where every NPC remembers, every action has a chance, and the story never stops.โ€


โœจ Wonderful Features at a Glance

Feature Description
๐Ÿ—๏ธ Layered World Building Every entity (character, location, item, faction, event, rule) has three layers: L1 (classification), L2 (detailed description), L3 (secrets). Generate incrementally, resume anytime.
๐Ÿ•ธ๏ธ Graphโ€‘First Knowledge All relationships stored in a directed graph. Traverse, visualise, and validate connections. Selfโ€‘healing graph repairs broken links automatically.
๐Ÿง  Selfโ€‘Optimising Memory FAISSโ€‘accelerated vector memory for NPCs and world events. Background consolidation, pruning, clustering, and timeโ€‘based partitioning.
๐ŸŽฒ Probability System Deterministic outcomes for combat, persuasion, stealth, romance, investigation, etc. Dynamic parameters (skill, health, mood, environment, luck) with temporary modifiers. No more arbitrary LLM decisions.
๐Ÿ’– Romance System Full romantic relationship management โ€“ affection, compatibility, status (crush/dating/engaged/married). Probabilityโ€‘driven actions: flirt, confess, date, kiss, propose, breakup.
๐ŸŒฑ Advanced Birth / Isekai Probabilityโ€‘based race, social class, magic affinity, innate talents. Full threeโ€‘generation family tree, heirlooms, family secrets. Optional reincarnation mode with cheat ability and pastโ€‘life memories.
๐ŸŽญ Living Narrative Director Background agent advances story arcs, villain agendas, NPC interactions, chance events, and scheduled story beats โ€“ even when youโ€™re not playing.
๐Ÿ’ฌ Immersive Roleplay Thirdโ€‘person narrative, NPC dialogue, scene transitions. The LLM never speaks or acts for your character. Natural language actions, movement, and slash commands.
๐Ÿ“œ Quest & Social System Dynamic quest generation, objective tracking, social simulation between NPCs (alliances, betrayals, arguments).
๐ŸŒฟ World Evolution The Director periodically adds new NPCs, locations, and items based on story progression. The world grows organically.
๐ŸŒฟ Branching Storylines Create alternate branches without touching the main graph โ€“ merge them back when ready.
๐Ÿง  Pain Signals The system learns from failures โ€“ pain keywords trigger warnings, helping the narrative avoid repeating mistakes.
๐Ÿ”Œ Unified CLI & Web UI One command (world newgame) launches the full experience. Beautiful terminalโ€‘style web interface with realโ€‘time memory, romance, and probability dashboards.
๐Ÿ› ๏ธ Oneโ€‘Command New Game world newgame --hints "noble mage half-elf" --isekai creates a complete world, a unique character with family tree, and starts the web UI.

๐Ÿงฑ Architecture Overview (v2)

User (CLI / Web UI)
    โ”‚
    โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                      world_cli.py (unified)                 โ”‚
โ”‚   Routes to builder, explorer, intelligence, narrative,     โ”‚
โ”‚   and new commands: newgame, continue, serve                โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                              โ”‚
                              โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                      RoleplayEngine                          โ”‚
โ”‚  (narrator / NPC / scene agents, probability system,        โ”‚
โ”‚   romance engine, memory, start resolver)                   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
               โ”‚                              โ”‚
               โ–ผ                              โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚      StoryEngine         โ”‚    โ”‚        Director            โ”‚
โ”‚  (event generation,      โ”‚    โ”‚ (villains, story planner,  โ”‚
โ”‚   effect application,    โ”‚    โ”‚  NPC simulator, tick loop) โ”‚
โ”‚   probability actions)   โ”‚    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜                   โ”‚
               โ”‚                               โ”‚
               โ–ผ                               โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                 Unified EntityStore + GraphStore            โ”‚
โ”‚   O(1) name index, batch saves, mutation callbacks.        โ”‚
โ”‚   Lazy graph rebuild, branch manager.                      โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                              โ”‚
                              โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                     WorldMemory (FAISS)                     โ”‚
โ”‚   Partitioned storage, embedding queue, writeโ€‘behind,      โ”‚
โ”‚   cognitive pipeline (entity extraction, contradiction,    โ”‚
โ”‚   pain signals), background optimizer.                     โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

All modules share world_db/ โ€“ everything is persistent, atomic, and crashโ€‘safe.


๐Ÿš€ Quick Start (5 minutes)

1. Install & Configure

git clone https://github.com/your-org/bring.git
cd bring

# Install core dependencies (adjust to your environment)
pip install -r world_builder/requirements.txt \
            -r world_explorer/requirements.txt \
            -r world_intelligence/requirements.txt \
            -r world_narrative/requirements.txt

# For FAISS (highly recommended)
pip install faiss-cpu   # or faiss-gpu if you have CUDA

Create a .env file:

# LLM (OpenAI or compatible)
LLM_API_KEY=your_openai_api_key
LLM_BASE_URL=https://api.openai.com/v1
LLM_MODEL=gpt-4o-mini

# Optional: Local embeddings (e.g., BGEโ€‘M3 via LiteLLM or local server)
EMBEDDING_BASE_URL=http://localhost:8043/v1
EMBEDDING_MODEL_NAME=bge-m3

# Database location
WORLD_DB_PATH=./world_db

2. Build Your First World (or jump straight to a new game)

# Classic: build world, layers, relationships
python -m world_builder.cli build --episodes 3 --relationships

# Or start a new game immediately (birth wizard + web UI)
python world_cli.py newgame --hints "a young elven ranger" --isekai

The newgame command:

  • Checks system (LLM, FAISS, disk space)
  • Prepares world (creates frame if missing)
  • Runs the advanced birth wizard (probability rolls for race, class, magic, talents)
  • Generates a full family tree, heirloom, and family secret
  • Schedules childhood milestones (first word, first step, magic awakening)
  • Launches the web UI at http://localhost:8000

3. Explore Your World

# CLI summary
python -m world_builder.cli view summary

# List all characters
python -m world_builder.cli view characters

# Detailed entity view
python -m world_builder.cli view entity "Kaelen" --level 2

# Semantic search
python -m world_explorer.cli search "ancient prophecy" --semantic

4. Play a Roleplay Session (CLI)

python -m world_narrative.cli play --character Kaelen --location Silverwood

Inside the session:

  • Natural language: I search the old chest for clues.
  • Talk to NPCs: talk to Elara "What do you know about the ruins?"
  • Move: go to Riverfall
  • Probability actions: /attack Goblin, /persuade Elara "We should help", /stealth
  • Romance: /romance Kaelen Elara (shows status), /romance-attempt confess --character Kaelen --target Elara
  • Slash commands: /look, /inventory, /status, /quests, /time, /save, /quit

The Director runs in the background โ€“ villains advance, chance events occur, story beats trigger.

5. Launch the Web UI (if not already open)

python world_cli.py serve --port 8000

Then open http://localhost:8000.
The UI provides a terminalโ€‘style interface with:

  • Realโ€‘time memory event feed
  • Character and romance dashboards
  • Quest tracking
  • Probability sparkline
  • Full command palette (Ctrl+K)

๐Ÿ—‚๏ธ Detailed Module Guides

1. ๐ŸŒ World Builder (world_builder)

Purpose: Create and expand the world skeleton.

Command Description Example
build Full world generation (resumable). python -m world_builder.cli build
add npc <faction/race> Add a new NPC on the fly. add npc "Order of the Echo"
add item <type> [--rarity] Add a new item. add item weapon --rarity rare
view entity <name> [--level] Show layered data. view entity "Kaelen" --level 2
validate Check relationship consistency. validate
repair [--intelligent] [--merge] [--create] Fix broken relationships (fuzzy matching + autoโ€‘create). repair --merge --create

Key improvement (v2): Batch saves and lazy graph rebuild drastically reduce I/O.


2. ๐Ÿ” World Explorer (world_explorer)

Purpose: Navigate the graph, visualise, manage branches, and now includes the full web UI.

Command Description Example
show <uid> [--layer l1] [--complete] Display entity data (autoโ€‘complete missing layers). show "Character:Kaelen" --layer l2
neighbors <uid> --depth 2 Show connected nodes. neighbors "Character:Kaelen" --depth 2
path <source> <target> Shortest path between entities. path "Kaelen" "Silverwood"
search --semantic <query> FAISSโ€‘accelerated semantic search. search --semantic "ancient magic sword"
branch create/switch/merge Manage story branches. branch create "what-if-kaelen-dies"
visualize Export interactive HTML graph. visualize --output world.html
layer [l1/l2/l3/all] Generate missing layers via builder. layer l2
serve Start the FastAPI web server (used by world_cli.py serve). serve --port 8000

New in v2: The web UI is now the primary interface for newgame. It includes realโ€‘time WebSocket feeds for memory and roleplay.


3. ๐Ÿง  World Intelligence (world_intelligence)

Purpose: Analyse, recommend, and enrich the world automatically.

Command Description Example
analyze Centrality, communities, path stats. analyze
recommend Suggest missing relationships & new entities. recommend
generate-scene <uid> Create narrative scene from a graph cluster. generate-scene "Character:Kaelen"
check-rules [--fix] Validate all entities against world rules (LLM). check-rules --fix
expand <uid> [--depth] [--fix-rules] Enrich subgraph (complete layers, check rules, generate scene). expand "Location:Silverwood" --depth 2
enrich [--fix-rules] Full pipeline โ€“ layers, relationships, rules, recommendations, duplicates. enrich --fix-rules
deduplicate [--dry-run] FAISSโ€‘accelerated duplicate merging. deduplicate

v2 performance: All duplicate detection and relationship repair now use FAISS and tries, making them O(log n) instead of O(nยฒ).


4. ๐Ÿ“– World Narrative (world_narrative)

Purpose: Run the living story โ€“ director, roleplay, probability, romance, memory, quests.

Command Description Example
newgame Oneโ€‘command launch โ€“ birth wizard + web UI. world newgame --hints "noble mage" --isekai
continue Resume existing game from snapshot or session. world continue --session-id mygame
play Start CLI roleplay session. play --character Kaelen --session mygame
tick <ISO_time> Manually advance story and generate event. tick 2025-01-01T12:00:00
timeline [--since] [--group] Show event log. timeline --since 2025-01-01
schedule <callback> <minutes> <data> Schedule future event. schedule villain_event 30 '{"villain":"The Shadow"}'
npc-status <name> Show NPC memory, health, mood, goals, inventory. npc-status Elara
director-status Show villain progress, story plan. director-status
birth Advanced character creator (family tree, isekai). birth --hints "half-elf druid" --isekai
romance-status/attempt/list/gift Manage romantic relationships. romance-attempt confess --character Kaelen --target Elara
prob show/list/modify/skills Probability system introspection. prob show combat --character Kaelen --target Goblin
memory-maintenance/status/forget/summarise/export/import Advanced memory management. memory-maintenance --full

Director background loop: Wakes every 60 real seconds, advances story time by 30 minutes, processes NPC interactions, villain ticks, chance events, and scheduled story beats.


5. ๐ŸŽฒ Probability System (world_core/probability)

Now integrated into RoleplayEngine and StoryEngine. Used for:

  • Combat โ€“ /attack
  • Persuasion โ€“ /persuade
  • Stealth โ€“ /stealth
  • Intimidation โ€“ /intimidate
  • Deception โ€“ /deception
  • Romance โ€“ all romance actions
  • Birth โ€“ race, social class, magic affinity, talents
  • Quest objectives โ€“ chanceโ€‘based objectives

Profiles: combat, persuasion, stealth, romance, investigation, athletics, deception, intimidation, generic, birth_race, birth_social_class, birth_magic_affinity, birth_talent.

Modifiers: temporary bonuses/penalties via /prob modify.


6. ๐Ÿ’– Romance System (world_core/romance)

Automatically tracks relationships between characters. CLI commands:

  • romance-status --character Kaelen --target Elara
  • romance-attempt confess --character Kaelen --target Elara --location "Moonlight Garden"
  • romance-list --status dating
  • romance-gift --character Kaelen --target Elara --gift "Silver Necklace"

Integration: Romance events are logged to the chronicler and can trigger director story arcs.


7. ๐Ÿš€ Professional Launcher (world_narrative/launcher.py)

Used internally by newgame and continue. Features:

  • System check โ€“ verifies LLM, FAISS, disk space.
  • World preparation โ€“ creates world frame if missing.
  • Memory health check โ€“ runs consolidation before start.
  • Birth wizard โ€“ probability rolls + LLM generation.
  • Postโ€‘birth tasks โ€“ repairs relationships, schedules childhood milestones, adds welcome quest.
  • Snapshot save/load โ€“ instantly resume games.

8. ๐Ÿ”Œ World Core (world_core)

New components:

  • UnifiedEntityStore โ€“ O(1) name resolution, batch saves, mutation callbacks.
  • EventBus โ€“ decoupled publish/subscribe for all modules.
  • WorldMemory โ€“ FAISSโ€‘based, partitioned, selfโ€‘optimising.
  • ProbabilityEngine โ€“ deterministic rolls with modifiers.
  • RomanceEngine โ€“ relationship management.

๐ŸŽฎ Roleplay Session โ€“ Inโ€‘Depth Example

Start a new game with web UI:

python world_cli.py newgame --hints "a young elven ranger named Kaelen" --isekai

The browser opens with a terminalโ€‘style interface.
You see the opening narrative (birth scene), family tree, and a status panel.

Now type actions in the web UI input box:

> I look around the forest clearing.

[Narrator] Sunlight filters through the ancient oaks, dappling the mossy ground. A small stream babbles nearby. You notice a worn path leading east, and a strange symbol carved into a stone.

Talk to an NPC:

> talk to Elara "Do you know about the symbol on that stone?"

Elara says: "Ah, that's the mark of the Wardens. They used to guard this forest, but they vanished a century ago. Some say a curse drove them out."

Use probability actions:

> /attack Goblin

[Narrator] Kaelen attacks Goblin: success (prob 72%, roll 0.34). The goblin takes 10 damage!

Check romance status:

> /romance-status --character Kaelen --target Elara

๐Ÿ’– Kaelen & Elara
Status: crush
Affection: 55%
Compatibility: 68%
Stage: attraction

Attempt a confession:

> /romance-attempt confess --character Kaelen --target Elara --location "Moonlight Garden"

โœ… Confess result: Kaelen confesses his feelings to Elara amazingly. She accepts!

The relationship updates to dating.


๐Ÿงช Advanced Usage & Tips

๐Ÿ“Œ Branching Storylines

world branch create what-if-kaelen-dies
world branch switch what-if-kaelen-dies
# Make changes (delete edges, add nodes)
world branch merge what-if-kaelen-dies

๐Ÿ“Œ Starting Point Resolution (CLI)

world narrative play --start "as Kaelen in the Silverwood forest at dawn, just after a storm"

๐Ÿ“Œ Probability Modifiers

Give Kaelen a temporary +20% combat boost for 5 minutes:

world narrative prob modify Kaelen combat_skill 0.2 --duration 300

๐Ÿ“Œ Memory Maintenance

world narrative memory-maintenance --full   # prune, merge, archive
world narrative memory-status
world narrative memory-forget 30 --min-importance 0.2
world narrative memory-summarise --tag "isekai"

๐Ÿ“Œ Enriching an Existing World

world intel enrich --fix-rules

๐Ÿ“Œ Visualising the Graph

world explore visualize --output myworld.html
# open myworld.html in a browser

๐Ÿ“Œ Running the API Server Separately

world serve --port 8000

The API includes endpoints for:

  • /api/launch โ€“ create new game
  • /api/continue โ€“ resume session
  • /ws/roleplay/{session_id} โ€“ realโ€‘time narrative WebSocket
  • /ws/memory โ€“ realโ€‘time memory event stream
  • /api/romance/... โ€“ romance queries
  • /api/probability/... โ€“ probability queries
  • /api/maintenance/... โ€“ trigger maintenance

๐Ÿ› ๏ธ Configuration Reference

All settings via environment variables (.env).

Category Variable Default Description
LLM LLM_API_KEY "" API key (OpenAI or compatible).
LLM_BASE_URL https://api.openai.com/v1 Endpoint.
LLM_MODEL gpt-4o-mini Model name.
LLM_MAX_RETRIES 5 Retries on failure.
LLM_RATE_LIMIT_RPS 3.0 Requests per second.
LLM_MAX_CONCURRENT 8 Concurrent LLM calls.
LLM_TIMEOUT 120.0 Total request timeout (seconds).
Embeddings EMBEDDING_BASE_URL http://localhost:8043/v1 Embedding API.
EMBEDDING_MODEL_NAME bge-m3 Embedding model.
EMBEDDING_BATCH_SIZE 64 Batch size for API calls.
Paths WORLD_DB_PATH ./world_db Database directory.
Behaviour AUTO_HEAL True Autoโ€‘repair graph on explorer boot.
DEAD_REF_TYPE BROKEN Edge type for unresolvable references.
Probability (no env vars; modifiers saved in world_db/probability_modifiers.json)
Romance (data stored in world_db/romance/)

๐Ÿ“ Full Project Tree (Abridged)

bring/
โ”œโ”€โ”€ world_builder/          # World generation
โ”‚   โ”œโ”€โ”€ builder.py          # Main orchestrator (batch saves, event bus)
โ”‚   โ”œโ”€โ”€ cli.py              # Typer CLI
โ”‚   โ”œโ”€โ”€ generator.py        # LLM prompt calls
โ”‚   โ”œโ”€โ”€ graph_manager.py    # Unified API over EntityStore
โ”‚   โ””โ”€โ”€ ...
โ”œโ”€โ”€ world_explorer/         # Graph navigation & web UI
โ”‚   โ”œโ”€โ”€ cli.py
โ”‚   โ”œโ”€โ”€ store.py            # GraphStore with unified store
โ”‚   โ”œโ”€โ”€ navigator.py        # Queries (neighbors, path, search)
โ”‚   โ”œโ”€โ”€ branch_manager.py
โ”‚   โ”œโ”€โ”€ api.py              # FastAPI (serves UI + REST + WebSocket)
โ”‚   โ”œโ”€โ”€ templates.py        # Inline HTML/JS UI
โ”‚   โ””โ”€โ”€ routes/             # Modular API routes
โ”œโ”€โ”€ world_intelligence/     # Analysis & enrichment (FAISS accelerated)
โ”‚   โ”œโ”€โ”€ cli.py
โ”‚   โ”œโ”€โ”€ graph_analyzer.py
โ”‚   โ”œโ”€โ”€ recommender.py
โ”‚   โ”œโ”€โ”€ rule_checker.py
โ”‚   โ”œโ”€โ”€ duplicate_detector.py (FAISS)
โ”‚   โ”œโ”€โ”€ relationship_repairer.py (Trie + fuzzy)
โ”‚   โ””โ”€โ”€ pipeline.py
โ”œโ”€โ”€ world_narrative/        # Story & roleplay
โ”‚   โ”œโ”€โ”€ cli.py (includes newgame, continue, romance, prob)
โ”‚   โ”œโ”€โ”€ context.py          # Dependency injection (memory, probability, romance)
โ”‚   โ”œโ”€โ”€ story_engine.py
โ”‚   โ”œโ”€โ”€ director.py         # Unified background director
โ”‚   โ”œโ”€โ”€ memory_optimized.py # NPC memory
โ”‚   โ”œโ”€โ”€ birth.py            # Advanced character creation (family tree, isekai)
โ”‚   โ”œโ”€โ”€ launcher.py         # Professional game launcher
โ”‚   โ””โ”€โ”€ ...
โ”œโ”€โ”€ world_engine/           # Roleplay agents (probability actions)
โ”œโ”€โ”€ world_director/         # Task queue, arcs, evolution
โ”œโ”€โ”€ world_core/             # Shared infrastructure
โ”‚   โ”œโ”€โ”€ models.py           # LayeredProfile, EntityNode, WorldFrame
โ”‚   โ”œโ”€โ”€ store.py            # UnifiedEntityStore (O(1) lookups)
โ”‚   โ”œโ”€โ”€ event_bus.py        # Async pub/sub
โ”‚   โ”œโ”€โ”€ history_manager.py  # Persistent session turns
โ”‚   โ”œโ”€โ”€ probability/        # Probability engine & profiles
โ”‚   โ”œโ”€โ”€ romance/            # Romance engine & models
โ”‚   โ””โ”€โ”€ memory/             # FAISSโ€‘based selfโ€‘optimising memory
โ”‚       โ”œโ”€โ”€ world_memory.py
โ”‚       โ”œโ”€โ”€ optimizer.py
โ”‚       โ”œโ”€โ”€ partition.py
โ”‚       โ””โ”€โ”€ ...
โ””โ”€โ”€ world_db/               # Persistent data (autoโ€‘created)

๐Ÿค Contributing

We welcome contributions! Please:

  1. Open an issue describing the change.
  2. Fork the repo and create a feature branch.
  3. Add tests for new features.
  4. Run black and isort (if configured).
  5. Submit a pull request.

Development setup:

git clone ...
cd bring
pip install -e .  # if you create a setup.py

Testing the new game pipeline:

python world_cli.py newgame --hints "test" --no-browser
python test_integration.py

๐Ÿ“œ License

MIT (or your chosen license)


Enjoy building and living in your worlds with BRING v2!
May your stories be legendary.

About

Next generation role-playing with LLM - with AI world and intelligent NPCs and multi-faceted Graph memory for all entities and a rich pipline and multi agent

Topics

Resources

License

Stars

Watchers

Forks

Contributors

Languages