smart-babylon-library v1.1.1

Deterministic infinite library generator inspired by Borges' "The Library of Babel"

Generate unique, deterministic books and pages based on coordinate systems without storing any data.

Python Generator Deterministic Library PyPI Research

smart-babylon-library — a deterministic infinite library generator inspired by Borges' "The Library of Babel". Generate unique, deterministic books and pages based on coordinate systems without storing any data.

⚠️ Project Status: Research & Development

IMPORTANT DISCLAIMER: This project is currently in active research and development phase. It is provided as-is for academic and experimental purposes only. No guarantees of stability, security, or fitness for any particular purpose are provided. Users assume all risks associated with usage.

Current Version: 1.1.1 (Multi-Universe Support)

  • Multi-Universe Support — Create isolated libraries with different configurations
  • Enhanced Configuration — Universe parameter for deterministic isolation
  • Complete JSON Integration — Universe field included in all serializations
  • Full Roundtrip Support — Serialize/deserialize with universe preservation
  • Universe-Based Determinism — Content generation isolated per universe

Version 1.0.1 (New Architecture):

  • Modular OOP Design — Clean separation of concerns
  • Enhanced Configuration — Flexible LibraryConfig system with character sets customization
  • JSON Serialization — Full object serialization support
  • Type Safety — Improved type hints and validation
  • Research Integration — Implements concepts from published papers

Legacy Version: 0.6.5 (Deprecated)

Version 0.6.5 and earlier are no longer supported. Users of older versions should migrate to 1.0.0+.

This library implements concepts from our published research:

  • Deterministic Generation — Same coordinates always produce the same content
  • Infinite Library — Virtually unlimited books and pages through coordinate system
  • Zero Storage — Content generated on-demand, nothing stored
  • Configurable — Customize book lengths, page sizes, and character sets
  • JSON Support — Full serialization to JSON format with universe support
  • Unicode Support — Cyrillic, Latin, digits, and punctuation
  • Multi-Universe — Create isolated libraries with different configurations

pip install smart-babylon-library

from smart_babylon_library import SmartBabylonLibrary

# Create library instance
library = SmartBabylonLibrary()

# Get a book by coordinates
book = library.get_book(floor=1, room=3, cabinet=2, shelf=5, book_number=42)

print(f"Book: {book}")
print(f"Title: {book.title}")
print(f"Pages: {book.max_pages}")

# Access specific page
page = book.get_page(0)
print(f"Page content: {page.content}")

Library now supports multiple parallel universes - each with its own deterministic content:

from smart_babylon_library import SmartBabylonLibrary, LibraryConfig

# Different universes - different content
fantasy_config = LibraryConfig(universe="middle_earth")
scifi_config = LibraryConfig(universe="andromeda_galaxy")

fantasy_library = SmartBabylonLibrary(fantasy_config)
scifi_library = SmartBabylonLibrary(scifi_config)

# Same coordinates, different content
fantasy_book = fantasy_library.get_book(1, 1, 1, 1, 1)
scifi_book = scifi_library.get_book(1, 1, 1, 1, 1)

print(fantasy_book.title != scifi_book.title)  # True

# Universe is included in JSON serialization
print(fantasy_book.to_json())  # Includes 'universe' field

Each item is located using 6-dimensional coordinates:

  • floor — Library floor
  • room — Room number
  • cabinet — Cabinet number
  • shelf — Shelf number
  • book — Book number
  • page — Page number

from smart_babylon_library import SmartBabylonLibrary, LibraryConfig
from smart_babylon_library.character_sets.alphabets import LatinAlphabet, CyrillicAlphabet
from smart_babylon_library.character_sets.digits import Digits

# Basic configuration
config = LibraryConfig(
    universe="my_library",              # Universe name
    title_length_range=(10, 100),      # Title length range
    content_length_range=(500, 2000),  # Page content length range
    pages_per_book_range=(5, 50)       # Pages per book range
)

# Custom character sets (only Latin and digits)
custom_config = LibraryConfig(
    universe="numeric_world",
    title_length_range=(10, 50),
    content_length_range=(200, 1000),
    pages_per_book_range=(5, 20),
    character_sets=[LatinAlphabet(), Digits()]
)

library = SmartBabylonLibrary(config)

SmartBabylonLibrary:

  • get_book(floor, room, cabinet, shelf, book_number) — Get book by coordinates
  • get_book_from_dict(coordinates_dict) — Get book from dictionary
  • get_book_json(coordinates_dict) — Get book as JSON string
  • get_page(floor, room, cabinet, shelf, book_number, page) — Get page by coordinates
  • get_page_from_dict(coordinates_dict) — Get page from dictionary
  • get_page_json(coordinates_dict) — Get page as JSON string

LibraryBook:

  • title — Book title (generated)
  • max_pages — Total pages in book
  • coordinates — Book coordinates
  • config — Library configuration with universe
  • get_page(page_number) — Get specific page
  • to_dict() — Convert to dictionary (includes universe)
  • to_json() — Convert to JSON (includes universe)

LibraryPage:

  • content — Page content (generated)
  • page_number — Page number
  • coordinates — Page coordinates
  • config — Library configuration with universe
  • to_dict() — Convert to dictionary (includes universe)
  • to_json() — Convert to JSON (includes universe)

Library supports configurable character sets. By default, includes all sets, but can be customized:

Built-in Character Sets:

  • CyrillicAlphabet() — Russian alphabet (upper and lower case)
  • LatinAlphabet() — English alphabet (upper and lower case)
  • Digits() — Numbers (0-9)
  • Punctuation() — Punctuation and symbols

Custom Character Sets:

from smart_babylon_library.character_sets.core import CharacterSet
from smart_babylon_library.library.config import LibraryConfig

class MyCharset(CharacterSet):
    @property
    def characters(self):
        chars = list("ABC123!@#")
        return sorted(chars)

    @property
    def name(self) -> str:
        return "My Custom Charset"

config = LibraryConfig(universe="custom_universe", character_sets=[MyCharset()])

Content generation is deterministic based on coordinates and universe:

# Same coordinates = same content
book1 = library.get_book(1, 1, 1, 1, 1)
book2 = library.get_book(1, 1, 1, 1, 1)

assert book1.title == book2.title
assert book1.get_page(0).content == book2.get_page(0).content

# Different universe = different content (even with same coordinates)
other_library = SmartBabylonLibrary(LibraryConfig(universe="other"))
book3 = other_library.get_book(1, 1, 1, 1, 1)

assert book1.title != book3.title  # Different universes

🚀 SMART BABYLON LIBRARY - COMPREHENSIVE DEMO
============================================================

🔹 1. BASIC LIBRARY USAGE
==================================================
📖 Book: Book '8g^Н,ВD|y7Тша|t`хGПхдя7Ъx"Ххg1...' (Universe: default)
📝 Title: 8g^Н,ВD|y7Тша|t`хGПхдя7Ъx"Ххg1AЪ32?#9бRW6Ия9фЪYQЪШaЁ.ЪЛe;4Hн...
📄 Total pages: 9782
📍 Coordinates: Floor1/Room3/Cabinet2/Shelf5/Book42/Page0
🌌 Universe: default

🔹 2. JSON SERIALIZATION WITH UNIVERSE
==================================================
📖 Book JSON includes 'universe' field
📃 Page JSON includes 'universe' field

🔹 3. MULTIPLE UNIVERSES
==================================================
Same coordinates across different universes:
  🧙 Fantasy World: Middle Earth
  🚀 Sci-Fi Galaxy: Andromeda
  🤖 Cyberpunk: Neo Tokyo
  🐫 Ancient Egypt: Pharaohs

✅ All titles are unique across universes

🔹 4. CUSTOM CHARACTER SETS
==================================================
🔢 Digits Only: '02795259743711'
🔤 Latin Only: 'RsjAstelGJw'
😊 Emoji Only: '🙂😯🥸🤪☹🤮'

🔹 5. DETERMINISTIC BEHAVIOR
==================================================
✅ Same coordinates = same content
✅ Different coordinates = different content
✅ Different universes = different content

🎉 DEMONSTRATION COMPLETE!

By using this software, you agree to the full disclaimer terms.

Software provided "AS IS" without warranty. You assume all risks.

Full legal disclaimer: See DISCLAIMER.md

License: BSD 3-Clause License

Links


Created by Alexander Suvorov

Copyright © 2026, Alexander Suvorov