I once made a Markov Chatbot
//Code by Brian Smith
//Please give credit if used
//Version 1.0
function getChar(%this,%n)
{
return getSubStr(%this,%n,%n);
}
function Markov::addLine(%this,%line)
{
%lastWord = "";
//%line = stripBad(%line);
for(%i=0;%i<getWordCount(%line);%i++)
{
%word = getWord(%line,%i);
if(%lastWord $= "")
{
if(strPos(%this.startNodes,%word) < 0)
%this.startNodes = trim(%this.startNodes SPC %word);
}
else
{
%nodeStr = %this.node[%lastWord];
if(strPos(%nodeStr,%word) < 0)
%this.node[%lastWord] = trim(%this.node[%lastWord] SPC %word);
}
%lastWord = %word;
}
if(%i > %this.max)
%this.max = %i;
}
function getRandomWord(%line)
{
%cnt = getWordCount(%line);
%num = getRandom(0,%cnt);
if(%num >= %cnt)
%num--;
//echo(%cnt SPC %num);
return getWord(%line,%num);
}
function Markov::generateLine(%this,%len)
{
if(%len < 2)
return -1;
else
{
%startNode = getRandomWord(%this.startNodes);
//echo(%startNode);
%lastWord = %startNode;
%str = %startNode;
for(%i=0;%i<%len - 1;%i++)
{
%nodeStr = %this.node[%lastWord];
//echo(%nodestr);
if(strLen(%nodeStr) > 0)
%word = getRandomWord(%nodeStr);
else
{
break;
//%word = "." SPC getRandomWord(%this.startNodes); //%nodeStr);//
//%len = %len + 3;
}
//echo(%word);
%lastWord = %word;
%str = %str SPC %word;
//echo(%str);
}
}
return %str;
}
this is the thing i made