Note: Drunk Trump has been shut down, mainly because he wasn't super funny but was still taking up valuable quota in my Google Custom Search API key. He still lives on via his previous Tweets though.


I can't say I'm a fan of Donald Trump, or ever have been, but his popularity in the early stages of the GOP portion of the 2016 presidential campaign has been everything from baffling, to amusing to terrifying and I honestly don't know what to think about it.

What I do know is if you Markov chain his rather insane presidental announcement speech it becomes DrunkTrumpBot.

Markov what?

Markov chaining is a fairly simple concept where you just switch the state of thing without any memory of the previous state. For example if you have three possible states then five transitions could be: A to B to A to B to C or A to B to C to A to B. The system has no memory of anything but the current state.

This can be applied to language where a word is a state and possible next states are words that happen after that word. For example:

Original Text:
"A man, a plan, a canal, Panama."

States (normalized):
a, man, plan, canal, panama

a:      [ man, plan, canal ],
man:    [ a ], 
plan:   [ a ],
canal:  [ panama ],
panama: []

So in this (basic) example if we begin in state 'a' we can then transition to any three states: man, plan or canal. From within one of those states we can transition back to 'a' (from man and plan) or to panama (via canal). Possible results from this could be:

a man a man a man a plan a man a plan a canal panama
a man a canal panama
a man a plan a plan a plan a canal panama

Our initial dictionary is very small, so how interesting of a sentence we can generate is pretty limited (it will always end with 'canal panama'). However if you use the text of, say, a presidential announcement speech, you have a much larger dictionary to work with and you can generate some pretty weird things.

Trump's speech already reads a little bit like the ramblings of a crazy person, so Markov chaining it only takes what already exists and amplifies it. This bot was originally just named 'RealTrumpBot' but I decided to rebrand it since it kind of sounds like stuff a really drunk person would say.

What Else?

The bot pulls a random image from a Google Image Search for "donald trump" of course. It does some cropping/resizing and then pastes the quote in there. Nothing too exciting.

As with all of my bots, this runs on Bot Farm, which is in a less than optimal state for release, so putting the source code out there is delayed until I get that into better shape. Some day though.

As always, I'm on Twitter if you have any questions or comments.