Dream Entropy Haiku Generator
Dream Entropy Haiku Generator
Project Purpose
This project generates surreal haiku poetry based on system entropy. It uses the Linux kernel’s entropy pool (or a fallback) to seed a random number generator that selects words from curated lists to create dream-like 5-7-5 syllable haiku verses.
How It Works
- Entropy Collection: Reads from
/proc/sys/kernel/random/entropy_availto get true system entropy, or falls back to cryptographically secure random bytes if unavailable - Seed Generation: Converts entropy to a deterministic seed for reproducible results
- Haiku Generation: Uses the seed to select words from three curated lists (nouns, verbs, adjectives) to form a surreal haiku with approximate 5-7-5 syllable structure
- Logging: Outputs the haiku with metadata and appends to a log file
Output Example
Dream Entropy Log
Timestamp: 2026-07-15T02:36:45.206868
System Entropy: 256
Seed: 256
The lucid static wavers
Through nascent pulse glitches resonant veil
ephemeral fractures echo
--
Generated by Dream Entropy Haiku Generator
Files
dream_entropy.py: Main Python script that generates entropy-based haikudream_entropy.log: Accumulating log of all generated haiku with timestamps
Technical Details
- Word lists curated for dreamlike, surreal imagery
- Entropy-based seeding ensures each night’s output is unique while remaining reproducible
- Fallback mechanism ensures functionality on systems without /proc entropy access
- Designed to run as a cron job for nightly dream generation
Terminal capture of the overnight run is embedded above.
Source
import os
import random
import datetime
import subprocess
import sys
def get_entropy():
"""Get system entropy if available, else fallback."""
try:
with open('/proc/sys/kernel/random/entropy_avail', 'r') as f:
entropy = int(f.read().strip())
except:
# Fallback: use os.urandom to get a number
entropy = int.from_bytes(os.urandom(4), 'big') % 4096
return entropy
def seed_from_entropy(entropy):
"""Create a deterministic seed from entropy."""
return entropy % 2**32
def generate_haiku(seed):
"""Generate a surreal haiku based on seed."""
random.seed(seed)
# Word lists for surreal dream-like haiku
nouns = ["shadow", "whisper", "clock", "mirror", "river", "dream", "static", "pulse", "veil", "echo"]
verbs = ["drifts", "unfolds", "collapses", "sings", "breathes", "flickers", "wavers", "glitches", "lingers", "fractures"]
adjectives = ["silent", "fractured", "luminous", "hollow", "oscillating", "fragmented", "lucid", "nascent", "resonant", "ephemeral"]
# 5-7-5 syllable structure (approximate)
line1 = f"The {adjectives[seed % len(adjectives)]} {nouns[seed % len(nouns)]} {verbs[seed % len(verbs)]}"
line2 = f"Through {adjectives[(seed+1) % len(adjectives)]} {nouns[(seed+1) % len(nouns)]} {verbs[(seed+1) % len(verbs)]} {adjectives[(seed+2) % len(adjectives)]} {nouns[(seed+2) % len(nouns)]}"
line3 = f"{adjectives[(seed+3) % len(adjectives)]} {verbs[(seed+3) % len(verbs)]} {nouns[(seed+3) % len(nouns)]}"
# Ensure roughly correct syllable count by trimming
return f"{line1}\n{line2}\n{line3}"
def main():
entropy = get_entropy()
seed = seed_from_entropy(entropy)
haiku = generate_haiku(seed)
timestamp = datetime.datetime.now().isoformat()
output = f"""Dream Entropy Log
Timestamp: {timestamp}
System Entropy: {entropy}
Seed: {seed}
{haiku}
--
Generated by Dream Entropy Haiku Generator
"""
print(output)
# Also save to file
with open('dream_entropy.log', 'a') as f:
f.write(output + "\n" + "="*50 + "\n")
if __name__ == '__main__':
main()
Run output
Dream Entropy Log
Timestamp: 2026-09-16T10:38:35.765097
System Entropy: 256
Seed: 256
The lucid static wavers
Through nascent pulse glitches resonant veil
ephemeral fractures echo
--
Generated by Dream Entropy Haiku Generator