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.
Smart Babylon Library is a deterministic infinite library generator inspired by Borges' 'The Library of Babel'. It generates unique, deterministic books and pages based on a 6-dimensional coordinate system without storing any data.
Version 1.1.1 adds powerful Multi-Universe Support and enhanced JSON serialization, allowing you to create isolated libraries with different configurations where the same coordinates produce different content across universes.
Each item is located using 6-dimensional coordinates:
floor — Library floorroom — Room numbercabinet — Cabinet numbershelf — Shelf numberbook — Book numberpage — Page numberDifferent universes produce different content for the same coordinates, allowing for isolated libraries with different configurations:
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
Installation
pip install smart-babylon-library
Basic Usage
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}")
Basic Configuration:
from smart_babylon_library import SmartBabylonLibrary, LibraryConfig
# 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
)
library = SmartBabylonLibrary(config)
Custom Character Sets:
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
# 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(custom_config)
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 symbolsSmartBabylonLibrary — Main Library Class
get_book(floor, room, cabinet, shelf, book_number) — Get book by coordinatesget_book_from_dict(coordinates_dict) — Get book from dictionaryget_book_json(coordinates_dict) — Get book as JSON stringget_page(floor, room, cabinet, shelf, book_number, page) — Get page by coordinatesget_page_from_dict(coordinates_dict) — Get page from dictionaryget_page_json(coordinates_dict) — Get page as JSON stringLibraryBook — Book Class
title — Book title (generated)max_pages — Total pages in bookcoordinates — Book coordinatesconfig — Library configuration with universeget_page(page_number) — Get specific pageto_dict() — Convert to dictionary (includes universe)to_json() — Convert to JSON (includes universe)LibraryPage — Page Class
content — Page content (generated)page_number — Page numbercoordinates — Page coordinatesconfig — Library configuration with universeto_dict() — Convert to dictionary (includes universe)to_json() — Convert to JSON (includes universe)
# Get book as JSON (includes universe)
book_json = library.get_book_json({
'floor': 1, 'room': 1, 'cabinet': 1,
'shelf': 1, 'book': 1, 'page': 0
})
# Get page as JSON (includes universe)
page_json = library.get_page_json({
'floor': 1, 'room': 1, 'cabinet': 1,
'shelf': 1, 'book': 1, 'page': 42
})
print(book_json) # Includes 'universe' field
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
Current Version: 1.1.1 (Multi-Universe Support)
Version 1.0.1 (New Architecture):
⚠️ Legacy 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:
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.
Full legal disclaimer: See DISCLAIMER.md
License: BSD 3-Clause License