示例#1
0
def newInstr(input_var):

	newMood=getMood(input_var) # update mood based on user input

	GLOB['PREVMOOD']=copy.deepcopy(GLOB['MOOD'])
	inputWeight = 1.0 - GLOB['MOOD'][2] # more confident -> less impact by other people
	GLOB['MOOD']=updateMood(newMood, weight=[inputWeight]*3+[0]*(GLOB['MOODDIM']-3))

	retVal, cmd = "", ""
	for task in extractCommands(input_var):
		retVal, cmd =determineFunction(task)

		if len(task.strip()) == 0: continue

		memAdded = addAutobiographicMemory()
		if not memAdded:
			mem, conf, memType = autobiographicRecall()
			recalled = rememberMemory(mem, conf, memType)

	if cmd == "none":
		confusedAnimation()
	else:
		deltaMoodQuery(fromAuto=True)

	face=getFace(GLOB['MOOD'])
	setFace(face=face[2])

	blinkingAnimation(mood=GLOB['MOOD'])
			
	GLOB['prevUsageTime'] = time.time()
	GLOB['remindersSent'] = 0

	if retVal == "exit":
		exitEvent()
示例#2
0
def suggestCommand(inCmd=[], inStr="", perform=False, fromAuto=False, matches=[[],[]]):
	CMDHIST = GLOB['CMDHIST']

	if not perform:
		perform = wordSim(inStr, "do what you want") >= 0.85

	cmdList, nameList = generateCmdList()

	if len(cmdList) == 0:
		if not fromAuto:
			say("I'm not sure what to do.", more=False, moodUpdate=True, speak=setting("SPEAK"))
		return True

	topCmd, topDelta, topUserCmd = longTermSatisfactionMaximization(cmdList, nameList)
	
	# only do something autonomously if the need has enough weight
	#   and you are not too lazy

	if not perform:
		
		rStr=processResponse(getResponse(inCmd), [topCmd])

		#print "top cmd: ", topUserCmd 
		rStr += ' ('+'%s'%k.sf(topDelta,2)+')'
		say(rStr, more=False, moodUpdate=True, speak=setting("SPEAK"))

	else:
		# say same thing as user when he issued command
		#print "top cmd: ", topUserCmd
		# only do thing if outcome is expected to be positive
		offLimits = ["suggestCommand", "none", "wrongCmd", "goodbye", "reminders"] # not allowed to do these
		if topDelta >= setting('LAZINESS') and topCmd not in offLimits:
			#print "performing: ", topUserCmd
			toSay='*'+topUserCmd+'*'
			say(toSay, more=False, moodUpdate=True, fromAuto=False, describeFace=True, speak=False, location="top")

			
			if fromAuto:

				# AI manually calls determineFunction
				retVal, cmd = determineFunction(topUserCmd)
				if retVal == "new prompt":
					newInput(findCMD("newInput"))
			else:
				# suggestion was called by determineFunction
				return [topUserCmd, True]

		else:
			if not fromAuto:
				retStr = "I'm okay."
				say(retStr, more=False, moodUpdate=True, speak=setting("SPEAK"))

	return True
示例#3
0
def newInstr(input_var):

    newMood = getMood(input_var)  # update mood based on user input

    GLOB['PREVMOOD'] = copy.deepcopy(GLOB['MOOD'])
    inputWeight = 1.0 - GLOB['MOOD'][
        2]  # more confident -> less impact by other people
    GLOB['MOOD'] = updateMood(newMood,
                              weight=[inputWeight] * 3 + [0] *
                              (GLOB['MOODDIM'] - 3))

    retVal, cmd = "", ""
    for task in extractCommands(input_var):
        retVal, cmd = determineFunction(task)

        if len(task.strip()) == 0: continue

        memAdded = addAutobiographicMemory()
        if not memAdded:
            mem, conf, memType = autobiographicRecall()
            recalled = rememberMemory(mem, conf, memType)

    if cmd == "none":
        confusedAnimation()
    else:
        deltaMoodQuery(fromAuto=True)

    face = getFace(GLOB['MOOD'])
    setFace(face=face[2])

    blinkingAnimation(mood=GLOB['MOOD'])

    GLOB['prevUsageTime'] = time.time()
    GLOB['remindersSent'] = 0

    if retVal == "exit":
        exitEvent()
示例#4
0
def suggestCommand(inCmd=[],
                   inStr="",
                   perform=False,
                   fromAuto=False,
                   matches=[[], []]):
    CMDHIST = GLOB['CMDHIST']

    if not perform:
        perform = wordSim(inStr, "do what you want") >= 0.85

    cmdList, nameList = generateCmdList()

    if len(cmdList) == 0:
        if not fromAuto:
            say("I'm not sure what to do.",
                more=False,
                moodUpdate=True,
                speak=setting("SPEAK"))
        return True

    topCmd, topDelta, topUserCmd = longTermSatisfactionMaximization(
        cmdList, nameList)

    # only do something autonomously if the need has enough weight
    #   and you are not too lazy

    if not perform:

        rStr = processResponse(getResponse(inCmd), [topCmd])

        #print "top cmd: ", topUserCmd
        rStr += ' (' + '%s' % k.sf(topDelta, 2) + ')'
        say(rStr, more=False, moodUpdate=True, speak=setting("SPEAK"))

    else:
        # say same thing as user when he issued command
        #print "top cmd: ", topUserCmd
        # only do thing if outcome is expected to be positive
        offLimits = [
            "suggestCommand", "none", "wrongCmd", "goodbye", "reminders"
        ]  # not allowed to do these
        if topDelta >= setting('LAZINESS') and topCmd not in offLimits:
            #print "performing: ", topUserCmd
            toSay = '*' + topUserCmd + '*'
            say(toSay,
                more=False,
                moodUpdate=True,
                fromAuto=False,
                describeFace=True,
                speak=False,
                location="top")

            if fromAuto:

                # AI manually calls determineFunction
                retVal, cmd = determineFunction(topUserCmd)
                if retVal == "new prompt":
                    newInput(findCMD("newInput"))
            else:
                # suggestion was called by determineFunction
                return [topUserCmd, True]

        else:
            if not fromAuto:
                retStr = "I'm okay."
                say(retStr,
                    more=False,
                    moodUpdate=True,
                    speak=setting("SPEAK"))

    return True