Nearly Perfect Mediocracy
Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

queneau-letters

1.0.3 • Public • Published

queneau-letters

A Queneau letter-chunks node module based on Leonard Richardson's algorithm

http://www.crummy.com/2011/08/18/0

Words made from letter-chunks

Many games have single-word titles, eg. "Carcassonne". I wanted to have single-word titles in BGD, but I didn't want to duplicate real names. So I applied the Queneau assembly algorithm on the word level.

Here, the chunk is a run of letters that's all vowels or all consonants. So "Carcassonne" would be split into the chunks ["C", "a", "rc", "a", "ss", "o", "nn", e"]. I keep two sets of buckets, one for vowels and one for consonants. If the first chunk was a vowel chunk, the second chunk is a consonant chunk, and I alternate til I reach the end.

This means that single-word BGD titles are almost never English words, but they do capture the feel of those one-word titles that aren't words (examples: "Zajekan", "Fraseda", "Kongin", "Q-blardo").

NPM js-standard-style Build Status

EXAMPLE

  var makeQueneau = require('quenea-letters')
  var queneauLetters = makeQueneau()
  var lines = fs.readFileSync('./lines.txt').toString().split('\n')
  queneauLetters.seed(lines)
  queneauLetters.fill(5)
  => wowwwowowowowowowowowowo // idk this will vary i guess

API

seed(lines) => slices up the lines into words into consonant/vowel runs and puts them in the appropriate bucket

generate(length) => randomly alternates between vowels and consonants until it has length number of consonant/vowel runs. note that length here does not mean string.length, i.e, ['w', 'o', 'rld'] would be valid for length 3.

install

npm i queneau-letters

Downloadsweekly downloads

16

version

1.0.3

license

MIT

repository

githubgithub

last publish

collaborators

  • avatar