Yakman
2010-05-03 21:38:12
This plugin has great potential for use in runescape autoing. It could be
taught by coding a script to make a bot stand around a crowded area for many
hours until the contexts / word ratio becomes high. Also a bot could learn
just by going about its business mining / woodcutting and listening to people talk.
You might have to let it learn for quite a long time before its responses seem okay.
If any of you keep chatlogs (wt-f :p) you will find them very valuable. If you
code a script to simply parse your chatlogs and pass them to MarkovRespondLearn()
you will very quickly teach it.
As the responces depend entirely on what input it receives, i suspect the responder
will end up sounding a lot like the average runescape player.
I feel the best way to go about putting this into SRL is to have a certain probability
that the bot will respond. Coding a procedure to crudely count the number of other
players could lead to a nice way of deciding this probability. I recommend an
exponential function, along the lines of 'p = exp(-r * c)' where p is the probability
of talking, c is the player count and r is a small number to be determined. Make
sure there is a different higher probability for talking when the player's nick
is detected. Also it may be a good idea to detect questions like 'mining level'
and handle them seperatly.
Make sure you call MarkovRespondSaveWords() periodically, perhaps in NextPlayer()
as it can take a long time for large word lists. Also make sure you print out
the statistics like context / word ratio in progress reports.
Word lists could be shared with confidence as there is an element of randomness,
it will be unlikely that two bots meeting each other with the same responder
will become suspicious to anybody. Also as bots go around the world they will
learn slightly different things.
Source and dll attached.
taught by coding a script to make a bot stand around a crowded area for many
hours until the contexts / word ratio becomes high. Also a bot could learn
just by going about its business mining / woodcutting and listening to people talk.
You might have to let it learn for quite a long time before its responses seem okay.
If any of you keep chatlogs (wt-f :p) you will find them very valuable. If you
code a script to simply parse your chatlogs and pass them to MarkovRespondLearn()
you will very quickly teach it.
As the responces depend entirely on what input it receives, i suspect the responder
will end up sounding a lot like the average runescape player.
I feel the best way to go about putting this into SRL is to have a certain probability
that the bot will respond. Coding a procedure to crudely count the number of other
players could lead to a nice way of deciding this probability. I recommend an
exponential function, along the lines of 'p = exp(-r * c)' where p is the probability
of talking, c is the player count and r is a small number to be determined. Make
sure there is a different higher probability for talking when the player's nick
is detected. Also it may be a good idea to detect questions like 'mining level'
and handle them seperatly.
Make sure you call MarkovRespondSaveWords() periodically, perhaps in NextPlayer()
as it can take a long time for large word lists. Also make sure you print out
the statistics like context / word ratio in progress reports.
Word lists could be shared with confidence as there is an element of randomness,
it will be unlikely that two bots meeting each other with the same responder
will become suspicious to anybody. Also as bots go around the world they will
learn slightly different things.
program new;
{.loaddll markovrespond}
{
Plugin documentation.
procedure MarkovRespondSetup(seed: Integer);
- Sets up responder. Seed is used to start a pseudorandom number gen.
procedure MarkovRespondLearn(line: string);
- Learns from the given line.
procedure MarkovRespondGenerateReply(line: string);
- Generates a responce using markov chains of the given line.
- Use MarkovRespondGetReply() to get the actual string.
function MarkovRespondGetReplyLength(): Integer;
- Returns the length of the string in characters of the responce. This must
- be used to call SetLength() on a string variable before it is passed
- to MarkovRespondGetReply()
procedure MarkovRespondGetReply(reply: string);
- Writes the reply string to the given parameter which must be prepared
- with SetLength()
function MarkovRespondSaveWords(filename: string): boolean;
- Saves the words learned to a file, can be loaded again
- with MarkovRespondLoadWords(), returns false if failed.
function MarkovRespondLoadWords(filename: string): boolean;
- Loads words from file that came from MarkovRespondSaveWords(), returns
- false if failed.
procedure MarkovRespondGetStats(var wordcount, contextcount, linecount: Integer);
- Gets the statistics of the internal state.
}
var
request, reply: string;
procedure MarkovPrintStats;
var
wordcount, contextcount, linecount: Integer;
begin
MarkovRespondGetStats(wordcount, contextcount, linecount);
if(wordcount = 0)then
wordcount:= 1;
writeln('I know ' + IntToStr(wordcount) + ' words (' +
IntToStr(contextcount) + ' contexts, ' +
FloatToStr(contextcount * 1.0 / wordcount) + ' per word), ' +
IntToStr(linecount) + ' lines.');
end;
begin
MarkovRespondSetup(Random($7fffffff));
MarkovRespondLearn('hello world');
MarkovRespondLearn('world hello');
{
if(not MarkovRespondLoadWords('lines.txt'))then
begin
writeln('failed to open file');
TerminateScript;
end;
}
MarkovPrintStats;
request:= 'hello'; //Readln('talk to the bot');
MarkovRespondGenerateReply(request);
SetLength(reply, MarkovRespondGetReplyLength);
MarkovRespondGetReply(reply);
writeln('reply:''' + reply + '''');
MarkovRespondSaveWords('lines.txt');
end.
Source and dll attached.