You will want to Enable JavaScript while exploring this website.

Because most of the projects I create are interactive, JavaScript is essential for experiencing my work.

Markov Chain Comic Books


Markov Chain Comic Books is a series of short story comic books in which the text is generated by the Python programming language. Something that I am interested in is how interaction, design, and computed systems tell a story. For this project, I would feed a Python script a random article, and I would receive one computer-generated sentence in return. I would then give that sentence a random assignment in the comic book so that it would begin to tell a funny, nonsensical story.

The Python script that I wrote is shown below, which I used along with a markov chain script written by my professor, Allison Parrish.

Skills Demonstrated:

Creative Coding, Storytelling

Technology Used:

Python, InDesign

Python Code

import sys import markov import random import pronouncing as pr import tracery from tracery.modifiers import base_english #Rhyming function def rhymeWord(enterWord):  rhyme = pr.rhymes(enterWord)  for line in rhyme:      line = line.strip()      rhyme = line.split(" ")      rhyme =" ".join(rhyme)  return rhyme num = 1 rules = { 'sleep':['spy', 'lap dancing', 'anal'], 'day':['some', 'suck', 'fuck', 'yucko', 'hey', 'crap'], 'mild':['risky and frisky', '"no big dealio"', '...yadada...', 'omg, but seriously'], 'virus':['freakiness', 'friend zone', 'one night stand'], 'Sex':['very hairy Sex', 'Unfortunately, I know, yes Sex', 'you better believe it, Sex'], 'blood':['like that red stuff that comes out from inside of you', 'probably red paint', 'oh it must be paint'], 'software':['kangaroo testicles', 'pure evil', 'on a good note'], 'Justin':['Hannah Montana', 'Ivanka Trump', 'Justin Bieber'], 'Musk':['some chick', 'a less than average guy', "somebody's cat"], 'ammunition':['cheetos', 'sexy underwear', 'romantic ice cream'], 'shooting':['partying', 'moaning', 'releasing'], 'Smith & Wesson':['afterparty', 'nonsense', 'intercourse'], } grammar = tracery.Grammar(rules) grammar.add_modifiers(base_english) #terms to rhyme with term = "zika" termTwo = "good" termThree = "The" termFour = "nuts" termFive = "take" words = {'sex':'game of cards', 'Sex':grammar.flatten('#Sex#'), 'trap':'hole', 'STI':'Nasty Ass', 'sit':'shit', 'sat':'spat', 'tree':'trailer park', 'firearm':'dildo', 'kid':'cousin', 'deaths':'parties', 'gun':'striper', 'Howard Schultz':'Bruce Wayne', 'Starbucks':'morning sex', '3':'bitch', 'Jarrod Glandt':'Bruce Wayne', 'day':grammar.flatten('#day#'), 'sleep':grammar.flatten('#sleep#'), 'mild':grammar.flatten('#mild#'), 'virus':grammar.flatten('#virus#'), 'blood':grammar.flatten('#blood#'), 'from':'to', 'using':'losing', "Zika":"Mr Zika's",'software':grammar.flatten('#software#'), 'Google':'nude grandma', 'computers':'cats', 'Justin':grammar.flatten('#Justin#'), 'hardware':'crazy, daisy', 'niche':'rock', 'coexist':'play sex', 'boxed':'avenged','Elon Musk':'Superman', 'Musk':grammar.flatten('#Musk#'), 'targets':'customers','Rifle':'Adult Toy', 'shot':'cheap shot', 'permit':'toy', 'killers':'striper fans', 'shooting':grammar.flatten('#shooting#'), 'concealed':'concealed sexuality', 'calibers':'toys', 'Smith & Wesson':grammar.flatten('#Smith & Wesson#'), 'Zika':str(rhymeWord(term)), 'good':str(rhymeWord(termTwo)), 'The':str(rhymeWord(termThree)), 'nuts':str(rhymeWord(termFour)), 'take':str(rhymeWord(termFive))} # define a dictionary hold = [] #Hold markov sentences text = sys.stdin.read() #Read the text model = markov.build_model(text.split(), num) #Use n-grams to build from markov generated = markov.generate(model, num) #Generate the new text group = ' '.join(generated) #Combine the separate words into one string for key in words:     group = group.replace(key, words[key]) # replacing text using a dictionary hold = group.split('.') #Split this string after each period print (random.choice(hold)) #Print a random sentence

Designed and developed by Steven Simon 2017.