https://github.com/wondermongering/stochastic-dream-weaver
Stochastic Dream Weaver: A Markovian Poetry Generator
https://github.com/wondermongering/stochastic-dream-weaver
computational-creativity computational-literature creative-coding digital-humanities generative-text markov-chains mathematical-literature mathematical-poetry poetry-generator poisson-processes probabilistic-models procedural-generation stochastic-processes
Last synced: 7 months ago
JSON representation
Stochastic Dream Weaver: A Markovian Poetry Generator
- Host: GitHub
- URL: https://github.com/wondermongering/stochastic-dream-weaver
- Owner: Wondermongering
- License: mit
- Created: 2025-03-02T02:37:18.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2025-03-02T03:06:50.000Z (8 months ago)
- Last Synced: 2025-03-03T03:30:21.076Z (8 months ago)
- Topics: computational-creativity, computational-literature, creative-coding, digital-humanities, generative-text, markov-chains, mathematical-literature, mathematical-poetry, poetry-generator, poisson-processes, probabilistic-models, procedural-generation, stochastic-processes
- Language: C++
- Homepage:
- Size: 21.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Stochastic Poetic Generator
A C++ program that generates evocative, dream-like text inspired by mathematical concepts, stochastic processes, and the poetry of Samuel Taylor Coleridge.
The beauty of this program is that it leverages randomization throughout - from the selection of concepts to the specific values used within descriptions - so every run will produce unique outputs. The mathematical underpinnings ensure that while the text is generative and stochastic, it maintains meaningful structure through the Markov transitions and mathematical frameworks.
## Overview
This program creates surreal, poetic descriptions by merging mathematical concepts with literary aesthetics. It combines:
- **Randomization techniques** to ensure unique outputs each run
- **Markov chains** to create coherent transitions between concepts
- **Linear algebra** (via Eigen) to extract eigenvectors for structuring the narrative flow
- **Stochastic processes** like Poisson distributions to simulate the random appearance of visions## Installation
### Prerequisites
- C++ compiler supporting C++11 or later
- [Eigen](https://eigen.tuxfamily.org) library for linear algebra operations### Building the Project
```bash
# Clone the repository
git clone https://github.com/tpellissari/stochastic-poet.git
cd stochastic-poet# Create build directory
mkdir build && cd build# Configure with CMake
cmake ..# Build
make
```## Usage
Simply run the compiled executable:
```bash
./stochastic_poet
```Each execution generates a unique sequence of poetically described mathematical concepts.
## Example Outputs
```
Coleridge's opium-drenched visions populate my daydreams like a chaotic dance, where patterns briefly emergeColeridge's opium-drenched visions populate my daydreams like eigenvectors of a shimmering covariance matrix, principal components whispering forgotten stanzas from the stochastic depths of Xanadu. The dominant eigenvector, (0.57, -0.33, 0.75), guides the dream's trajectory.
Coleridge's opium-drenched visions populate my daydreams following a Poisson process, λ=2.37 visions per hour, each a fleeting glimpse into the sublime and terrifying.
Coleridge's visions transition from a state of 'fractal' to singularities, points of infinite density where reality itself fractures
```## Technical Architecture
### 1. Random Number Generation
The `randomDouble` function creates floating-point numbers within specified ranges, powering the stochastic aspects of the program.### 2. Concept Description Generator
The `describeConcept` function takes mathematical concepts and transforms them into poetic phrases, varying based on random inputs.### 3. Markov Chain Implementation
A probabilistic model guides transitions between concepts, creating a structured yet unpredictable evolution of the generated text.### 4. Eigenvector Computation
For the "eigenvector" concept, the program generates a random covariance matrix and computes its eigenvectors using Eigen, incorporating these values directly into the output.### 5. Poisson Process Modeling
The program uses Poisson distributions to model the frequency of dream visions, adding another layer of mathematical structure.## Extending the Generator
You can add new concepts by extending the `describeConcept` function with additional mathematical or literary ideas:
```cpp
else if (concept == "your_new_concept") {
ss << "description that incorporates " << (value > 0.5 ? "positive variant" : "alternative variant");
}
```Don't forget to add your new concept to the `concepts` vector in both the `createTransitionMatrix` function and the `main` function.
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.