i just told you this is the exact problem that you would have trying to chain word by word
the word "you" ends the response 9 times out of 10 because theres a 90% chance that punctuation comes after the word "you"
as you give it more options you make it more random, unless you're going to try to think up strings that only share words where the paths intersect at cohesive points, and although that would be an interesting project, you're not going to do that
no matter how much you want it to language processing will never be possible with basic 2d logic like markov chains
a working implementation of an absorbing markov chain in a chat bot would be making two bots talk to each other
Code
string bot1, bot2
if bot1==hello
bot2==hi there
print bot2
if bot2==hi there
bot1==are u flirting with me?
print bot1
if bot1==are u flirting with me?
bot2== no i'm just trying to explain to you that markov chains are simple logic based on state changes and you can't use them to create anything dynamic
or directing it through multiple preset paths that make sense
Code
question="hi"
string response
if question = "hi"
response.add( "hi there" )
choice =randomly choose ["who","what","when","where","why"]
case choice
who: response.add("who are you?"); choice=["end"]
what: add("what's up?"); choice=["end"]
when: add("when did you get here?"); choice=["end"]
why: add("why are you talking to me?"); randomly choose choice=["end","dontend"]
where: add("where am i?");
if choice==end
response.add("\nwell? answer me! Now");
else if choice=="dontend"
response.add("\n NEVER FUCKING MIND DO WHATEVER YOU WANT WITH YOUR BROKEN BOT ")
print response
bayesian networks will work better
https://en.wikipedia.org/wiki/Bayesian_networkbut
Quote
In 1990 while working at Stanford University on large bioinformatic applications, Greg Cooper proved that exact inference in Bayesian networks is NP-hard.[20] This result prompted a surge in research on approximation algorithms with the aim of developing a tractable approximation to probabilistic inference. In 1993, Paul Dagum and Michael Luby proved two surprising results on the complexity of approximation of probabilistic inference in Bayesian networks.[21] First, they proved that there is no tractable deterministic algorithm that can approximate probabilistic inference to within an absolute error ɛ< 1/2. Second, they proved that there is no tractable randomized algorithm that can approximate probabilistic inference to within an absolute error ɛ < 1/2 with confidence probability greater than 1/2.
This post was edited by Ideophobe on Mar 16 2016 10:15pm