Ejemplo n.º 1
0
def handle_read_sock (source, condition):
	msg = source.read()
	#++++Test_de_fin_de_connexion++++
	if not msg:
		print "EOF from socket"
		sys.exit(0)
	
	#RECEPTION
	
	if msg == "++++reload++++":
		tr.reload()
		if do_stat:
			stat.load()
			stat.add_partie()
			stat.save()
	elif msg == "++++vote=robot++++":
		tr.view.set_active_button(False,False)
		if do_stat:
			stat.load()
			stat.vote(True,bot)
			stat.save()
		tr.print_text("info","La partie se termine")
		if(bot):
			tr.print_text("info","Le robot se fait demasquer")
			sock.send("++++robot=win++++")
		else:
			tr.print_text("info","Now you can say : I fail the turing test")
			sock.send("++++robot=loose++++")
	elif msg == "++++vote=human++++":
		tr.view.set_active_button(False,False)
		if do_stat:
			stat.load()
			stat.vote(False,bot)
			stat.save()
		tr.print_text("info","La partie se termine")
		if(bot):
			tr.print_text("info","Le robot se fait passer pour un humain")
			sock.send("++++human=loose++++")
		else:
			tr.print_text("info","Le joueur a reconnu que tu es un humain")
			sock.send("++++human=win++++")
	elif bot:
		tr.print_text("joueur",msg)
		databot=tr.cb.Ask(formating.to_bot(msg))
		time.sleep(random.randint(3,5))
		sock.send(databot)
		tr.print_text("bot",databot)

	else:
		#++++PRINT_text++++
		tr.print_text("joueur",msg)

		
	return True
Ejemplo n.º 2
0
def handle_read_sock(source, condition):
    msg = source.read()
    #++++Test_de_fin_de_connexion++++
    if not msg:
        print "EOF from socket"
        sys.exit(0)

    #RECEPTION

    if msg == "++++reload++++":
        tr.reload()
        if do_stat:
            stat.load()
            stat.add_partie()
            stat.save()
    elif msg == "++++vote=robot++++":
        tr.view.set_active_button(False, False)
        if do_stat:
            stat.load()
            stat.vote(True, bot)
            stat.save()
        tr.print_text("info", "La partie se termine")
        if (bot):
            tr.print_text("info", "Le robot se fait demasquer")
            sock.send("++++robot=win++++")
        else:
            tr.print_text("info", "Now you can say : I fail the turing test")
            sock.send("++++robot=loose++++")
    elif msg == "++++vote=human++++":
        tr.view.set_active_button(False, False)
        if do_stat:
            stat.load()
            stat.vote(False, bot)
            stat.save()
        tr.print_text("info", "La partie se termine")
        if (bot):
            tr.print_text("info", "Le robot se fait passer pour un humain")
            sock.send("++++human=loose++++")
        else:
            tr.print_text("info", "Le joueur a reconnu que tu es un humain")
            sock.send("++++human=win++++")
    elif bot:
        tr.print_text("joueur", msg)
        databot = tr.cb.Ask(formating.to_bot(msg))
        time.sleep(random.randint(3, 5))
        sock.send(databot)
        tr.print_text("bot", databot)

    else:
        #++++PRINT_text++++
        tr.print_text("joueur", msg)

    return True
Ejemplo n.º 3
0
# coding=utf-8
import cleverbot
import formating

cb1=cleverbot.Session()
cb2=cleverbot.Session()

r1 = cb1.Ask("Salut")
print "cb1 : Salut" 

while True:
	r2 = formating.from_bot(cb2.Ask(formating.to_bot(r1)))
	print "cb2 : {0}".format(r2)
	r1 = formating.from_bot(cb1.Ask(formating.to_bot(r2)))
        print "cb1 : {0}".format(r1)

Ejemplo n.º 4
0
# coding=utf-8
import cleverbot
import formating

cb1 = cleverbot.Session()
cb2 = cleverbot.Session()

r1 = cb1.Ask("Salut")
print "cb1 : Salut"

while True:
    r2 = formating.from_bot(cb2.Ask(formating.to_bot(r1)))
    print "cb2 : {0}".format(r2)
    r1 = formating.from_bot(cb1.Ask(formating.to_bot(r2)))
    print "cb1 : {0}".format(r1)