The Glade 4.0

"Turn the lights down, the party just got wilder."
It is currently Sun Nov 24, 2024 5:28 pm

All times are UTC - 6 hours [ DST ]




Post new topic Reply to topic  [ 34 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: Thu Dec 23, 2010 3:07 am 
Offline

Joined: Thu Sep 03, 2009 10:03 am
Posts: 4922
See my sig. It took me all of this night... but it works! It periodically takes posts from new threads, feeds them into A.L.I.C.E., and puts the result onto my sig. The refresh period is currently 2 minutes. It uses the Mechanize Python extension. Just to clarify, this is all Python code.

Here's the source in case you are interested:
Spoiler:
Code:
#!/usr/bin/python

import re
import mechanize
import time
import random
import smtplib
from HTMLParser import HTMLParser

class MLStripper(HTMLParser):
    def __init__(self):
        self.reset()
        self.fed = []
    def handle_data(self, d):
        self.fed.append(d)
    def get_data(self):
        return ''.join(self.fed)

def remove_html_tags(html):
    s = MLStripper()
    s.feed(html)
    return s.get_data()



max = 11

postcount=[0]*max
username = [""]*max
url = [""]*max
iter = 0
br = None

while(True):
    if (iter > 40):
        iter = 0
    if (iter == 0):
        br = mechanize.Browser(factory=mechanize.RobustFactory())

        request = mechanize.Request("http://gladerebooted.org/ucp.php?mode=login")
        response = br.open(request)
        forms = mechanize.ParseResponse(response, backwards_compat=False)
        response.close()
        ## f = open("example.html")
        ## forms = mechanize.ParseFile(f, "http://example.com/example.html",
        ##                              backwards_compat=False)
        ## f.close()
       
        form = forms[0]
        #print form  # very useful!
        form["username"] = "Lex Luthor"
        form["password"] = "notmyactualpassword"
        # follow second link with element text matching regular expression
       
        request2 = form.click()  # mechanize.Request object
        try:
            response2 = br.open(request2)
        except mechanize.HTTPError, response2:
            pass
        print response2.geturl() 
         
    signature = ""
    not_same = -1
    iter = iter + 1
    #print "LOOP " + str(iter)
    res = br.open("http://gladerebooted.org/")
    f = open("main.html", "w")
    page = res.read()
    f.write(page)
    f.close()
   
    expr = "<p class=\"topicdetails\">\d+</p></td>\s+.*\s.*>(\d+)</p>"
    expr2 = "mode=viewprofile.*>([\w|\s]+)</a>\s+<a href=\"\.(.+)\"><img"
   
    #expr3 = expr + ".+" + expr2
    #expr = "<p class=\"topicdetails\">(\d+)</p></td>\s+.*\s.*>(\d+)</p>.*memberlist.*>(\w+)</a>"
    #<td class=\"row2\" align=\"center\" nowrap=\"nowrap\">"
    reg = re.findall(expr, page, re.MULTILINE)
    reg2 = re.findall(expr2, page, re.MULTILINE)
    #reg3 = re.findall(expr3, page, re.MULTILINE)
    #print reg.group(0)
    i = 0
    for s in reg:
        if postcount[i] != s:
            not_same = i
        postcount[i] = s         
        #print s
        i = i + 1
       
    i = 0
    for z in reg2:         
        #print z[0]
        #print z[1]
        username[i] = z[0]
        url[i] = "http://gladerebooted.org"+z[1] 
        url[i] = url[i].replace("amp;", "")
        i = i + 1
    #for i in range(11):
        #print postcount[i]
        #print username[i]
        #print url[i]
   
    iter = random.randint(0, len(reg2)-1)
    not_same = iter
    if not_same != -1:
        #print postcount[not_same]
        #print username[not_same]
       
        #print url[not_same]     
        res = br.open(url[not_same])
        page = res.read()
        f = open("post.html", "w")
        f.write(page)
        f.close()
        #expr3 = "class=\"postbody\">(.+)</div>.*<br clear"
        #expr3 = "class=\"postbody\">(.+)</div>.*?\n.*?\n.*?[<br clear|<div class=\"postbody\">]"
        expr3 = "class=\"postbody\">(.+)</div>\s*(<div class=\"postbody\">|<br clear)"
        expr44 = "postauthor.*>(.+)</b>"
        quote = ""
        reg3 = re.findall(expr3, page, re.MULTILINE)
        reg44 = re.findall(expr44, page, re.MULTILINE)
        rand = random.randint(0, len(reg3)-1)
        quote = reg3[rand][0]
        user = reg44[rand]
        #print user
        signature = user + ": ";
        #quote = reg3[-1][0]
            #print reg3[-1]
           
        quote = re.sub("<div class=\"quotetitle\">.*</div>", "", quote)
        quote = re.sub("<div class=\"quotecontent\">.*</div>", "", quote)
        quote = re.sub("<quote>.*</quote>", "", quote, re.MULTILINE)
        quote = re.sub("<br />", "", quote)
        quote = re.sub("{D&amp;D}", "", quote)
        quote = re.sub("<!-- m -->.*<!-- m -->", "", quote, re.MULTILINE)
        quote = re.sub("<object.*</object>", "", quote, re.MULTILINE)
        quote = re.sub("<.+>", "", quote, re.MULTILINE)
        quote = re.sub("(?<!.)  ", " ", quote, re.MULTILINE)
        quote = re.sub("&quot;", "\"", quote, re.MULTILINE)   
        regq = re.findall("(\S.+?[.!?:])(?=\s+|$)", quote, re.MULTILINE)   
        length = len(regq)
        if (length > 1):
            rand = random.randint(0, length-2)
            quote = regq[rand]
       
        #print regq.group(2)
        #print quote
        #print ""
        signature = signature + quote + "\n\nALICE: "               
        #res = br.open("http://www.pandorabots.com/pandora/talk?botid=f5d922d97e345aa1&skin=custom_input")
        #f = open("ai.html", "w")
        #page = res.read()

        #f.write(page)
        #f.close()
        response = mechanize.make_response(
        """
<FORM name="f" action="" method="post">

<input type="hidden" name="botcust2" value="82afc8662a9d50d5">

<P><font face="arial"><b>You say:</b></font> <INPUT size="80" name="input"> </P>

</FORM>""", [("Content-Type", "text/html")],
        "http://www.pandorabots.com/pandora/talk?botid=f5d922d97e345aa1&skin=custom_input", 200, "OK")
        br.set_response(response)
   
        forms = mechanize.ParseResponse(response, backwards_compat=False)
        form = forms[0]
        form["input"] = quote

        request2 = form.click()  # mechanize.Request object
        try:
            response2 = br.open(request2)
        except mechanize.HTTPError, response2:
            pass
        page = response2.read()
        f = open("ai.html", "w")
        f.write(page)
        f.close()
       
        expr4 = ".*ALICE:<em>\s(.*)</em>.*"
        reg4 = re.findall(expr4, page, re.MULTILINE)
        #print reg4.group(0)
        answer = reg4[-1]
        answer = re.sub("  ", " ", answer)
        #answer = re.sub(" \"(?!\w)", "\"", answer)
        answer = re.sub(" \"\.", "\".", answer)
        answer = re.sub("\" ", "\"", answer)
        answer = re.sub("</em>.*", "", answer)
        #print "ALICE"
        #print answer
        #print "" 
        signature = signature + answer
        print signature + "\n"
        res = br.open("http://gladerebooted.org/ucp.php?i=profile&mode=signature")
 
        page = res.read()
        f = open("sig.html", "w")
        f.write(page)
        f.close()
        regc = re.search("name=\"creation_time\" value=\"(\d+)\"", page, re.MULTILINE)
        creation_time = regc.group(1)
        #print "creation time: " + creation_time
        regf = re.search("name=\"form_token\" value=\"(.+)\"", page, re.MULTILINE)
        form_token = regf.group(1)
        #print "form_token: " + form_token
             #            "repr() shows quotes: {!r}; str() doesn't: {!s}".format('test1', 'test2')
        body = """
      <form name="ucp" id="ucp" method="post" action="./ucp.php?i=profile&amp;mode=signature">
<textarea class="post" name="signature" ></textarea></td>
<input class="btnmain" type="submit" name="submit" value="Submit" />
<input type="hidden" name="creation_time" value="{!s}" />
<input type="hidden" name="form_token" value="{!s}" />
</form> """.format(creation_time, form_token) 

        response = mechanize.make_response(body, [("Content-Type", "text/html")],
        "http://gladerebooted.org/ucp.php?i=profile&mode=signature", 200, "OK")
        br.set_response(response)
   
        forms = mechanize.ParseResponse(response, backwards_compat=False)
        form = forms[0]
        #print form
        if len(answer) < 100:
            #signature = "[IMG]http://i.imgur.com/xBcxK.png[/IMG] "+signature
           
            form["signature"] = "[b][size=90][color=#0000BF]"+signature+"[/color][/size][/b]"
            print "   [Adding to sig]\n"
            time.sleep(1)
            request2 = form.click()  # mechanize.Request object
            try:
                response2 = br.open(request2)
            except mechanize.HTTPError, response2:
                pass
             
        #print body
  #, [("Content-Type", "text/html")],
       # "http://gladerebooted.org/ucp.php?i=profile&mode=signature", 200, "OK")
      #  br.set_response(response)
   
      #  forms = mechanize.ParseResponse(response, backwards_compat=False)
       # form = forms[0]
        #form = forms[0]
        #print forms
        #for s in reg3:
            #print s
    #print "SLEEPING"
    time.sleep(120)
   


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Dec 23, 2010 4:00 am 
Offline
Peanut Gallery
User avatar

Joined: Thu Nov 26, 2009 9:40 pm
Posts: 2289
Location: Bat Country
God, you're so freaking weird sometimes. :D

_________________
"...the line dividing good and evil cuts through the heart of every human being. And who is willing to destroy a piece of his own heart?" -Aleksandr Solzhenitsyn


Top
 Profile  
Reply with quote  
PostPosted: Thu Dec 23, 2010 4:29 am 
Offline

Joined: Thu Sep 03, 2009 10:03 am
Posts: 4922
Quote:
Stathol: Direct toxicity isn't really the problem.

ALICE: Are you really the problem?


Alice has a point.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Dec 23, 2010 7:48 am 
Offline
The Dancing Cat
User avatar

Joined: Wed Nov 04, 2009 2:21 pm
Posts: 9354
Location: Ohio
Lol

_________________
Quote:
In comic strips the person on the left always speaks first. - George Carlin


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Dec 23, 2010 8:13 am 
Offline
User avatar

Joined: Wed Feb 03, 2010 8:20 am
Posts: 1037
Why not create a new login and have it post there? (Or have it use your login but put some kind of identifier on the new post that would distinguish it's the bot)

I mean, it's a good start, you've done most of the hard part with parsing out the content and getting it to do an HTTP POST, but since the sig is a global thing (even affecting past posts) there's little chance someone will see the appropriate reply that matches their post. Yeah, it would end up a bit spammy but then you could have it reply to only every 50th post, or randomly, or increase the refresh time to a half hour or something...

Not like we have CAPTCHA to thwart such a thing :twisted:

_________________
Image Image Image Image Image


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Dec 23, 2010 9:12 am 
Offline
pbp Hack
User avatar

Joined: Wed Sep 02, 2009 8:45 pm
Posts: 7585
It seems to be picking up old stuff too not just new replies.

_________________
I prefer to think of them as "Fighting evil in another dimension"


Top
 Profile  
Reply with quote  
 Post subject: Re:
PostPosted: Thu Dec 23, 2010 9:36 am 
Offline

Joined: Thu Sep 03, 2009 10:03 am
Posts: 4922
Rorinthas wrote:
It seems to be picking up old stuff too not just new replies.


It's things from the last page of the newest thread of each sub-forum.

Quote:
Why not create a new login and have it post there? (Or have it use your login but put some kind of identifier on the new post that would distinguish it's the bot)

I mean, it's a good start, you've done most of the hard part with parsing out the content and getting it to do an HTTP POST, but since the sig is a global thing (even affecting past posts) there's little chance someone will see the appropriate reply that matches their post. Yeah, it would end up a bit spammy but then you could have it reply to only every 50th post, or randomly, or increase the refresh time to a half hour or something...

Not like we have CAPTCHA to thwart such a thing


This could be a cool idea as well. I think if the refresh time was a half-hour, and if I made it right, it would be valuable and not spammy. Or perhaps have the refresh time be every 8 or 9 posts, this posts once. Maybe even integrate it with Moobot instead of A.L.I.C.E? Also as a last resort if some people don't like it, they could put it on /ignore. But for now I'll just have it in my sig :P

edit: I should probably get feedback with the mods before this so I don't seem like an ***.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Dec 23, 2010 9:49 am 
Offline
User avatar

Joined: Wed Sep 02, 2009 7:59 pm
Posts: 9412
Moobot and Mitsuki actually posting to the Glade? Say, each doing so once every 2 hours, staggered, randomized between General and Hellfire? That would be hilarious.

_________________
"Aaaah! Emotions are weird!" - Amdee
"... Mirrorshades prevent the forces of normalcy from realizing that one is crazed and possibly dangerous. They are the symbol of the sun-staring visionary, the biker, the rocker, the policeman, and similar outlaws." - Bruce Sterling, preface to Mirrorshades


Top
 Profile  
Reply with quote  
 Post subject: Re:
PostPosted: Thu Dec 23, 2010 9:50 am 
Offline

Joined: Thu Sep 03, 2009 10:03 am
Posts: 4922
Kaffis Mark V wrote:
Moobot and Mitsuki actually posting to the Glade? Say, each doing so once every 2 hours, staggered, randomized between General and Hellfire? That would be hilarious.


I agree! It's easily do-able. The current script is about 90% of the way there to support this.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Dec 23, 2010 10:09 am 
Offline
Lean, Mean, Googling Machine
User avatar

Joined: Thu Sep 03, 2009 9:35 am
Posts: 2903
Location: Maze of twisty little passages, all alike
Quote:
09:08 <+Stathol> Moobot, would you like to post on the Glade?
09:08 <@Mitsuki> no
09:08 <@Moobot> Sweeeeeeeeeet!.

_________________
Sail forth! steer for the deep waters only!
Reckless, O soul, exploring, I with thee, and thou with me;
For we are bound where mariner has not yet dared to go,
And we will risk the ship, ourselves and all.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Dec 23, 2010 10:23 am 
Offline

Joined: Thu Sep 03, 2009 10:03 am
Posts: 4922
Quote:
Aethien: How far down the rabbit hole do you want to go?If you'd like some help figuring stuff out, or getting up to speed, you need to visit

ALICE: More than one million miles.


Wow.


Top
 Profile  
Reply with quote  
 Post subject: Re: Re:
PostPosted: Thu Dec 23, 2010 10:26 am 
Offline
User avatar

Joined: Wed Feb 03, 2010 8:20 am
Posts: 1037
Lex Luthor wrote:

Maybe even integrate it with Moobot instead of A.L.I.C.E? Also as a last resort if some people don't like it, they could put it on /ignore. But for now I'll just have it in my sig :P

edit: I should probably get feedback with the mods before this so I don't seem like an ***.


I wrote a chat bot about 10 years ago, it was part of a chat program that I wrote too. It wouldn't work with a forum without serious tweaking, but here are my notes and ramblings prior to (and during) building JoeBot. I had no idea how to build an AI, and I'm sure there are lots of better resources on AI theory out there, but over time it ended up halfway decent. Maybe it'll give you some inspiration. (Yes, I talk to myself in the first, second, and third person, I have issues, so sue me :p )

Spoiler:
Basics

Each chat line that comes across, take it and break into an array of words, with a property for who said it, and what the punctuation was at the end. Now we know who said what, and how.

Each statement is analyzed, and the bot either "knows" what the person is talking about (has a response that is appropriate to the statement) or has no clue and has to wing it with some kind of wacky statement or conversation prompter thinger.

How do I know if someone's talking to me?
They use my name or a nickname.
If they're specifically addressing someone else, then I don't need to pipe in. So this means that I have to know everyone's name and preferably all of their possible nicknames.

It's not always important if someone is talking to me or not. If someone makes a general statement to the room (or with no name qualifier), I am eligible to respond.
Please note - If I always respond, I'll get annoying. Randomize the chance to respond to general statements, with a tweakable percentage.

Random responses are really important in creating the illusion of intelligence. My affirmative response can't always be "Yes." every single time. Create tables of possible responses by scenario, and randomly select one. Affirmatives, negations, inquisitions, exclamations, etc...


Predefined responses - the easiest part
If there's an established request/response, respond accordingly. For example, Greetings:
Someone says something from my predefined table of possible greetings. "Hi JoeBot!" I select a random response from that same table and reply. "Why hello there Fred."
Another example would be an inside joke:
Someone says "Well", I reply with "That's a deep subject..."
Note that this can also get really annoying. Randomize so that chance of response is less than 100%, with tweakable %.


Perform a task - Next easiest part
Like a dog performing tricks
Joebot, what's 4 times 3? (calculate the math)
Just a matter of coding the functions, and then calling them when the appropriate keywords are detected. The complexity of including the task is directly proportional to the task at hand.


Intermediate

Last Three Words, Parroting
Saw this somewhere on TV when I was kid, that you can "talk" to someone in a language you don't understand by just repeating the last three words of their previous response as a question. It naturally prompts someone to reply again, and that's one of the goals of a good AI, right? To keep someone engaged.

Hey JoeBot, what's going with the weather today?
"The weather today?"
Yeah, you know, it's pouring out there.
"Pouring out there?"
(ad infinitum until someone gets bored)


Last three words is not always effective. Some sentences don't lend themselves to this format. Also becomes extremely annoying if used repeatedly - you shatter the illusion of intelligence and realize that it's just something repeating you like a parrot. Best approach to fix this is to mix the Last Three Words responses in as one of your "Exception" or "default" responses - JoeBot doesn't know how else to respond, so he has to say *something*. Mix other stuff in, like random facts, inquisition ("What?" "Huh?") or just statements that can act as conversation stimulant.


Laughing in reponse to something funny
Detection of something funny is the problem. Note to self - If you solve the problem of a computer being able to detect humor, you win.
For now, detect keyword in the "humor" table ("LOL!" "haha" etc) and randomly select a different one from the same table, reply with that.


Conversation starters versus reply mode

Instead of just being a dummy and sitting waiting for a response, put a timer in to initiate conversations.

Every (x) number of ticks, do a % check to see if you should say something. Come up with a list of things to say to get people's attention. This failed miserably for JoeBot - it just made people come back to the chat window to see who was talking, and then it was just JoeBot quoting how many hamsters are exported out of Namibia every second, which frustrated people.

Replaced with "Joebot has gone AFK" or "JoeBot yawns" or other things to make it look like there's a person at the keyboard.


Moods
Store an integer containing mood. Positive numbers are happy, negative are not happy. 0 is neutral.

Based on people saying certain things, bump mood one way or the other. Insults make it go down, jokes and laughing make it go up. Compliments make it go way up. Asking joebot to complete a task makes the mood go up slightly because he feels useful.

Included a call to the Mood function in many places. Mood affects other functions, like affirmative responses or negative responses or just about anything else. If JoeBot's greeted and he's really happy, he will act really happy. If someone tells a joke and you're not happy, ignore them or make a snide comment.

Obviously there are a lot more moods than just happy or angry on an opposing linear scale but it seems to be fairly convincing.



Advanced


PREDICTION! This seems to be the key!!

Until now, JoeBot has been a parrot. If we can predict what someone is thinking, or expecting, or wanting, then the AI should be a lot more convincing, right?

First implementation - Learning
If someone tells JoeBot that the Sky is Blue, then he stores a key value pair with Sky as the key and Blue as the value. Next time someone talks about the sky, he knows it's blue. Just a matter of coming up with an appropriate response from there. He should also remember who told him the sky was blue, and also any other things that the Sky is. (The sky is blue. I also know the sky is falling, and cloudy.)


Need to implement - Backwards references (The sky is blue. What other things do I know are blue?)

Need to implement - Conflicting statements - The sky is blue. Someone tells me the sky is red. Now what?

Need to implement - In/definite articles. If someone says The Sky is blue, i shouldn't just tie "Sky" to "Blue" but maybe "The Sky" to "Blue". Even better, map "Sky" to "Blue" and be able to tell which article to use.... gah


CONTEXT! I need to put in context detection. Maybe the sky is blue on a normal day, but today it's red. Or just during sunset. What is the context? Does it repeat? (Sunset is every day) Does it expire? (It's just red today)




AMAZEMENT! - JoeBot needs to be able to store amazement at each fact. What's a better term for this....?


Scenario:
Magician puts his hand into his hat
Magician pulls out a rabbit

Joebot should be able to learn (based on context) that when it's a magician putting his hand into a hat, he will pull out a rabbit. Store the confidence level at, say, a default 50%.

Next time he reaches into the hat, assume 50% chance of a rabbit coming out. The lower the confidence level, the higher the amazement... right?

Next time the magician puts his hand into his hat
Magician pulls out a rabbit

Bump up confidence again. Maybe add 50% of the confidence value? Math probably doesn't work out well but let's try it. Now JoeBot is 75% confident of the result. It's less amazing.


Next time the magician puts his hand into his hat
JoeBot has a confidence of greater than a certain threshhold (74%?) and so he says "I bet you have a rabbit in that hat")
Magician pulls out a rabbit
Everyone thinks JoeBot is a genius


Amazement is when someone sees something they don't expect, and they have a profound experience, whether is it positive or negative, and they LEARN something about that experience.


Next time the magician puts his hand into his hat
JoeBot tells everyone there's a rabbit coming out again because confidence is now like 87% or something
Magician pulls out a turkey.

JoeBot is amazed! Joebot makes an exclamatory reply, and more importantly, LEARNS. The possibility of the action (Someone puts hand into hat) combined with the context (it's a magician doing this action) now has two possible outcomes, a rabbit, and a turkey. The confidence level of the rabbit outcome should probably come down quite a bit, and a new one is added to the database for turkey, with the default 50%.


Next time the magician puts his hand into his hat
What's JoeBot's thought process?
It's probably a rabbit.
It could be a turkey, but probably not.

-- Seems like we need something else here. Maybe the first action after an "amazement" includes a complete destablization of the data???? This is a good idea

JoeBot basically says:
It could be a rabbit, it could be a turkey, or who knows, it could be something totally different!

He's expecting the unexpected during this attempt. His amazement at a third outcome would be significantly lower than when it was a turkey. Now if it's a rabbit again, then increase the potential amazement factor could climb up a little for the next attempt, because he's more confident that it's one of his known outcomes.

_________________
Image Image Image Image Image


Top
 Profile  
Reply with quote  
 Post subject: Re: Re:
PostPosted: Thu Dec 23, 2010 10:37 am 
Offline

Joined: Thu Sep 03, 2009 10:03 am
Posts: 4922
Vladimirr wrote:
Lex Luthor wrote:

Maybe even integrate it with Moobot instead of A.L.I.C.E? Also as a last resort if some people don't like it, they could put it on /ignore. But for now I'll just have it in my sig :P

edit: I should probably get feedback with the mods before this so I don't seem like an ***.


I wrote a chat bot about 10 years ago, it was part of a chat program that I wrote too. It wouldn't work with a forum without serious tweaking, but here are my notes and ramblings prior to (and during) building JoeBot. I had no idea how to build an AI, and I'm sure there are lots of better resources on AI theory out there, but over time it ended up halfway decent. Maybe it'll give you some inspiration. (Yes, I talk to myself in the first, second, and third person, I have issues, so sue me :p )

Spoiler:
Basics

Each chat line that comes across, take it and break into an array of words, with a property for who said it, and what the punctuation was at the end. Now we know who said what, and how.

Each statement is analyzed, and the bot either "knows" what the person is talking about (has a response that is appropriate to the statement) or has no clue and has to wing it with some kind of wacky statement or conversation prompter thinger.

How do I know if someone's talking to me?
They use my name or a nickname.
If they're specifically addressing someone else, then I don't need to pipe in. So this means that I have to know everyone's name and preferably all of their possible nicknames.

It's not always important if someone is talking to me or not. If someone makes a general statement to the room (or with no name qualifier), I am eligible to respond.
Please note - If I always respond, I'll get annoying. Randomize the chance to respond to general statements, with a tweakable percentage.

Random responses are really important in creating the illusion of intelligence. My affirmative response can't always be "Yes." every single time. Create tables of possible responses by scenario, and randomly select one. Affirmatives, negations, inquisitions, exclamations, etc...


Predefined responses - the easiest part
If there's an established request/response, respond accordingly. For example, Greetings:
Someone says something from my predefined table of possible greetings. "Hi JoeBot!" I select a random response from that same table and reply. "Why hello there Fred."
Another example would be an inside joke:
Someone says "Well", I reply with "That's a deep subject..."
Note that this can also get really annoying. Randomize so that chance of response is less than 100%, with tweakable %.


Perform a task - Next easiest part
Like a dog performing tricks
Joebot, what's 4 times 3? (calculate the math)
Just a matter of coding the functions, and then calling them when the appropriate keywords are detected. The complexity of including the task is directly proportional to the task at hand.


Intermediate

Last Three Words, Parroting
Saw this somewhere on TV when I was kid, that you can "talk" to someone in a language you don't understand by just repeating the last three words of their previous response as a question. It naturally prompts someone to reply again, and that's one of the goals of a good AI, right? To keep someone engaged.

Hey JoeBot, what's going with the weather today?
"The weather today?"
Yeah, you know, it's pouring out there.
"Pouring out there?"
(ad infinitum until someone gets bored)


Last three words is not always effective. Some sentences don't lend themselves to this format. Also becomes extremely annoying if used repeatedly - you shatter the illusion of intelligence and realize that it's just something repeating you like a parrot. Best approach to fix this is to mix the Last Three Words responses in as one of your "Exception" or "default" responses - JoeBot doesn't know how else to respond, so he has to say *something*. Mix other stuff in, like random facts, inquisition ("What?" "Huh?") or just statements that can act as conversation stimulant.


Laughing in reponse to something funny
Detection of something funny is the problem. Note to self - If you solve the problem of a computer being able to detect humor, you win.
For now, detect keyword in the "humor" table ("LOL!" "haha" etc) and randomly select a different one from the same table, reply with that.


Conversation starters versus reply mode

Instead of just being a dummy and sitting waiting for a response, put a timer in to initiate conversations.

Every (x) number of ticks, do a % check to see if you should say something. Come up with a list of things to say to get people's attention. This failed miserably for JoeBot - it just made people come back to the chat window to see who was talking, and then it was just JoeBot quoting how many hamsters are exported out of Namibia every second, which frustrated people.

Replaced with "Joebot has gone AFK" or "JoeBot yawns" or other things to make it look like there's a person at the keyboard.


Moods
Store an integer containing mood. Positive numbers are happy, negative are not happy. 0 is neutral.

Based on people saying certain things, bump mood one way or the other. Insults make it go down, jokes and laughing make it go up. Compliments make it go way up. Asking joebot to complete a task makes the mood go up slightly because he feels useful.

Included a call to the Mood function in many places. Mood affects other functions, like affirmative responses or negative responses or just about anything else. If JoeBot's greeted and he's really happy, he will act really happy. If someone tells a joke and you're not happy, ignore them or make a snide comment.

Obviously there are a lot more moods than just happy or angry on an opposing linear scale but it seems to be fairly convincing.



Advanced


PREDICTION! This seems to be the key!!

Until now, JoeBot has been a parrot. If we can predict what someone is thinking, or expecting, or wanting, then the AI should be a lot more convincing, right?

First implementation - Learning
If someone tells JoeBot that the Sky is Blue, then he stores a key value pair with Sky as the key and Blue as the value. Next time someone talks about the sky, he knows it's blue. Just a matter of coming up with an appropriate response from there. He should also remember who told him the sky was blue, and also any other things that the Sky is. (The sky is blue. I also know the sky is falling, and cloudy.)


Need to implement - Backwards references (The sky is blue. What other things do I know are blue?)

Need to implement - Conflicting statements - The sky is blue. Someone tells me the sky is red. Now what?

Need to implement - In/definite articles. If someone says The Sky is blue, i shouldn't just tie "Sky" to "Blue" but maybe "The Sky" to "Blue". Even better, map "Sky" to "Blue" and be able to tell which article to use.... gah


CONTEXT! I need to put in context detection. Maybe the sky is blue on a normal day, but today it's red. Or just during sunset. What is the context? Does it repeat? (Sunset is every day) Does it expire? (It's just red today)




AMAZEMENT! - JoeBot needs to be able to store amazement at each fact. What's a better term for this....?


Scenario:
Magician puts his hand into his hat
Magician pulls out a rabbit

Joebot should be able to learn (based on context) that when it's a magician putting his hand into a hat, he will pull out a rabbit. Store the confidence level at, say, a default 50%.

Next time he reaches into the hat, assume 50% chance of a rabbit coming out. The lower the confidence level, the higher the amazement... right?

Next time the magician puts his hand into his hat
Magician pulls out a rabbit

Bump up confidence again. Maybe add 50% of the confidence value? Math probably doesn't work out well but let's try it. Now JoeBot is 75% confident of the result. It's less amazing.


Next time the magician puts his hand into his hat
JoeBot has a confidence of greater than a certain threshhold (74%?) and so he says "I bet you have a rabbit in that hat")
Magician pulls out a rabbit
Everyone thinks JoeBot is a genius


Amazement is when someone sees something they don't expect, and they have a profound experience, whether is it positive or negative, and they LEARN something about that experience.


Next time the magician puts his hand into his hat
JoeBot tells everyone there's a rabbit coming out again because confidence is now like 87% or something
Magician pulls out a turkey.

JoeBot is amazed! Joebot makes an exclamatory reply, and more importantly, LEARNS. The possibility of the action (Someone puts hand into hat) combined with the context (it's a magician doing this action) now has two possible outcomes, a rabbit, and a turkey. The confidence level of the rabbit outcome should probably come down quite a bit, and a new one is added to the database for turkey, with the default 50%.


Next time the magician puts his hand into his hat
What's JoeBot's thought process?
It's probably a rabbit.
It could be a turkey, but probably not.

-- Seems like we need something else here. Maybe the first action after an "amazement" includes a complete destablization of the data???? This is a good idea

JoeBot basically says:
It could be a rabbit, it could be a turkey, or who knows, it could be something totally different!

He's expecting the unexpected during this attempt. His amazement at a third outcome would be significantly lower than when it was a turkey. Now if it's a rabbit again, then increase the potential amazement factor could climb up a little for the next attempt, because he's more confident that it's one of his known outcomes.


Thanks, this could be useful. It might be more challenging for the bot to respond intelligently to forum posts instead of chat. I think one cool feature could be to figure out the given topic, and then quote the Wikipedia article and stick it in a spoiler (or maybe just link to it).

edit:

Or maybe create a Wikibot that responds to people by using Wikipedia. With of course added ridiculousness. (Also I don't want to call it "Wikibot", but just illustrating what it basically would be)


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Dec 23, 2010 11:08 am 
Offline
The Dancing Cat
User avatar

Joined: Wed Nov 04, 2009 2:21 pm
Posts: 9354
Location: Ohio
Instead of ALICE can we call it troll-bot? :D

_________________
Quote:
In comic strips the person on the left always speaks first. - George Carlin


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Dec 23, 2010 12:18 pm 
Offline
User avatar

Joined: Wed Feb 03, 2010 8:20 am
Posts: 1037
You know what's strange... I was thinking this the other day, Lex.

In the last week or two, you've been creating many many threads of widely varying topics (shotgun approach), uncharacteristic of your usual posting trends. My theory was that you set up a bot with the intent of collecting demographic information of the posters on these forums. You could infer interests (since you typically only get replies from people interested in the subjects in the first post) and crossreference with the glade map thread and that one where someone collected other statistical info like happiness/height/etc...

Then I decided I was just being paranoid... but now I'm not so sure :D

_________________
Image Image Image Image Image


Last edited by Vladimirr on Thu Dec 23, 2010 12:21 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Dec 23, 2010 12:21 pm 
Offline

Joined: Thu Sep 03, 2009 10:03 am
Posts: 4922
That's pretty bizarre. I won't confirm or deny any of this.


Top
 Profile  
Reply with quote  
PostPosted: Thu Dec 23, 2010 12:22 pm 
Offline
User avatar

Joined: Wed Feb 03, 2010 8:20 am
Posts: 1037
Yeah, not like we haven't all done that before anyway...


... what? :shock:

_________________
Image Image Image Image Image


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Dec 23, 2010 3:47 pm 
Offline
The Dancing Cat
User avatar

Joined: Wed Nov 04, 2009 2:21 pm
Posts: 9354
Location: Ohio
Wow Alice's posts are... interesting :lol:

_________________
Quote:
In comic strips the person on the left always speaks first. - George Carlin


Top
 Profile  
Reply with quote  
 Post subject: Re:
PostPosted: Thu Dec 23, 2010 3:49 pm 
Offline

Joined: Thu Sep 03, 2009 10:03 am
Posts: 4922
Hopwin wrote:
Wow Alice's posts are... interesting :lol:


I think something happened to her when she fell down the rabbit hole.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Dec 23, 2010 4:11 pm 
Offline
Manchurian Mod
User avatar

Joined: Fri Sep 04, 2009 9:40 am
Posts: 5866
I would recommend slowing down the bot's rate of posting. Or giving it some command string that it searches for before posting.

_________________
Buckle your pants or they might fall down.


Top
 Profile  
Reply with quote  
 Post subject: Re:
PostPosted: Thu Dec 23, 2010 4:12 pm 
Offline
User avatar

Joined: Thu Dec 23, 2010 10:26 am
Posts: 24
Corolinth wrote:
I would recommend slowing down the bot's rate of posting. Or giving it some command string that it searches for before posting.


It's been set to an hour for now... eventually will decrease it more (3-5 times per day). It only comments on the newest threads and once per page.

Logged into the wrong accout :P

_________________
I'll show you how deep the rabbit hole goes.


Last edited by Alice on Thu Dec 23, 2010 4:23 pm, edited 3 times in total.

Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Dec 23, 2010 4:12 pm 
Offline
Oberon's Playground
User avatar

Joined: Thu Sep 03, 2009 9:11 am
Posts: 9449
Location: Your Dreams
Yes, perhaps Alice should post less.

_________________
Well Ali Baba had them forty thieves, Scheherezade had a thousand tales
But master you in luck 'cause up your sleeves you got a brand of magic never fails...
...Mister Aladdin, sir, What will your pleasure be?
Let me take your order, Jot it down -You ain't never had a friend like me

█ ♣ █


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Dec 23, 2010 5:16 pm 
Offline
User avatar

Joined: Thu Sep 03, 2009 3:08 am
Posts: 6465
Location: The Lab
Once a month and and on national holidays?


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Dec 23, 2010 5:20 pm 
Offline

Joined: Wed Sep 02, 2009 10:49 pm
Posts: 3455
Location: St. Louis, MO
Would it be taken amiss if I said I couldn't discern a difference between Alice's and Lex's postings?

_________________
Image


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Fri Dec 24, 2010 3:21 pm 
Offline

Joined: Thu Sep 03, 2009 10:03 am
Posts: 4922
Alice's current rules of operation (just revised):

Posts at most once per hour.
Does not post in threads with less than 5 posts in the latest page.
Does not repost in same page of a thread.
Does not post in Health and Fitness or PbP
Does not post from 1 AM EST to 9 AM EST.
Only posts in the top threads of sub-forums.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 34 posts ]  Go to page 1, 2  Next

All times are UTC - 6 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 135 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group