Markov Cocktail

You can find and interact with @MarkovCocktail on Twitter.

He's a relatively simple bot that sends out tweets at prescribed times and responds to mentions. The results are...varied:

So how does he work? Where do these mind-blowingly dumb tweets come from? Let me tell you about Markov chains...

By definition Markov chains are, "a stochastic model describing a sequence of possible events in which the probability of each event depends only on the state attained in the previous event."

So they're probability models that can predict an arbitrary event based on past event states. So....layman's terms?
If I inputted this data set-
AAB
ABA
AAC
AAD
ABB
ACA
AAD
and then modeled a three letter Markov chain beginning with the letter A I would likely get:
AAA
simply based on the data, the next most likely letter after A is actually another A.

This can sometimes lead to to nonsensical word loops when it comes to @MarkovCocktail see:

Ok cool Mr. Wizard, but how do we get a derpy twitter bot from that...?
Why, everyone's favorite web library nodejs of course!

I setup my own simple twitter bot based off this fine piece of code github which uses the twit node package then I sprinkled in a little markov-magic with this makrovchain node library and voila- twitter bot that will tweet and reply with markov chains based off textual input you provide! Full code is available on github.

I intend to flesh this post out a little more in the future. I have a couple of changes planned for our friend @MarkovCocktail

Show Comments