public override Boolean Run(List <object> parameterList, out string targetContext, out string targetID) { string currOrigin = ""; string currInterest = ""; base.Run(parameterList, out targetContext, out targetID); string outputString = outputAction.GetString(ownerAgent.RandomNumberGenerator, null); MemoryItem origSought = ItemHandler.PopItem(ownerAgent, AgentConstants.QUERY_TAG_3); MemoryItem interestSought = ItemHandler.PopItem(ownerAgent, AgentConstants.QUERY_TAG_4); if (origSought != null) { currOrigin = (string)origSought.GetContent(); } if (interestSought != null) { currInterest = (string)interestSought.GetContent(); } if (currOrigin != "") { string interest = "interest"; //puts <Q3> = currOrigin, <Q4> = currDestination, <Q5> = currTime ownerAgent.SendSpeechOutput(ItemHandler.PutTermsOnTaggedString(outputString, new List <string> { AgentConstants.QUERY_TAG_3, AgentConstants.QUERY_TAG_4 }, new List <string> { currOrigin, currInterest })); ItemHandler.StoreTermOnTag(ownerAgent, AgentConstants.QUERY_TAG_3, currOrigin); ItemHandler.StoreTermOnTag(ownerAgent, AgentConstants.QUERY_TAG_4, currInterest); ItemHandler.StoreTermOnTag(ownerAgent, AgentConstants.QUERY_TAG_5, interest); //signifies that this is an interestSearch } //If the user did not try to add a value, assume he wants to cancel else { ownerAgent.SendSpeechOutput("Okay then."); targetContext = denyContext; targetID = denyID; return(true); } targetContext = outputAction.TargetContext; targetID = outputAction.TargetID; return(true); }
public override Boolean Run(List <object> parameterList, out string targetContext, out string targetID) { base.Run(parameterList, out targetContext, out targetID); string timePrefixString = outputAction.GetString(ownerAgent.RandomNumberGenerator, null); string timeString = DateTime.Now.Hour.ToString() + " " + DateTime.Now.Minute.ToString(); if (timePrefixString != null) { timeString = timePrefixString + " " + timeString; } ownerAgent.SendSpeechOutput(timeString); targetContext = outputAction.TargetContext; targetID = outputAction.TargetID; return(true); }
public override Boolean Run(List <object> parameterList, out string targetContext, out string targetID) { base.Run(parameterList, out targetContext, out targetID); string prefixString = outputAction.GetString(ownerAgent.RandomNumberGenerator, null); //The one outputaction pattern string travelDialogue = ""; string prevString = ""; string travelInfo = ""; string currOrigin = ""; string currDestination = ""; string currTime = ""; foreach (string query in speechQueries) { MemoryItem itemSought = ItemHandler.PopItem(ownerAgent, query); if (itemSought == null) { prevString = ""; continue; } string itemSoughtString = (string)itemSought.GetContent(); Console.WriteLine(itemSought.ToString() + " " + itemSought.GetContent()); if (itemSoughtString == "") { prevString = ""; continue; } if (prevString == "to") { currDestination = itemSoughtString; travelInfo += ItemHandler.SEP + ItemHandler.DESTINATION + currDestination; } else if (prevString == "from") { currOrigin = itemSoughtString; travelInfo += ItemHandler.SEP + ItemHandler.ORIGIN + currOrigin; } else if (prevString == "at") { currTime = itemSoughtString; travelInfo += ItemHandler.SEP + ItemHandler.TIME + currTime; } travelDialogue += " " + itemSoughtString; prevString = itemSoughtString; } /* * //clears all queries * StringMemoryItem matchMemoryClean = new StringMemoryItem(); * matchMemoryClean.TagList = speechQueries; * matchMemoryClean.SetContent(""); * ownerAgent.WorkingMemory.AddItem(matchMemoryClean); */ //puts <Q3> = currOrigin, <Q4> = currDestination, <Q5> = currTime ItemHandler.StoreTermOnTag(ownerAgent, AgentConstants.QUERY_TAG_3, currOrigin); ItemHandler.StoreTermOnTag(ownerAgent, AgentConstants.QUERY_TAG_4, currDestination); ItemHandler.StoreTermOnTag(ownerAgent, AgentConstants.QUERY_TAG_5, currTime); Console.WriteLine(currDestination + " " + currOrigin + " " + currTime); if (currOrigin != "" && currDestination != "") { ownerAgent.SendExpression("squinteyes"); //ownerAgent.SendSpeechOutput(prefixString + travelDialogue); //mapControl.NavigateDestination(currDestination, currOrigin, currTime); targetID = outputAction.TargetID; } else if (currOrigin == "" && currDestination == "") { ownerAgent.SendExpression("shakehead"); ownerAgent.SendSpeechOutput("I'm sorry I could not make out your origin or destination."); targetContext = ""; targetID = ""; return(false); } else { string missingLocation = ""; if (currOrigin != "") { missingLocation = "destination"; } else { missingLocation = "origin"; } ownerAgent.SendSpeechOutput(partialFailurePrefix[random.Next(partialFailurePrefix.Length - 1)] + missingLocation); targetID = partialFailureID; } //(TRAVEL_MARK + travelInfo); Console.WriteLine(travelInfo); targetContext = outputAction.TargetContext; return(true); }
public override Boolean Run(List <object> parameterList, out string targetContext, out string targetID) { base.Run(parameterList, out targetContext, out targetID); List <StringMemoryItem> queryMemoryItemList = new List <StringMemoryItem>(); if (queryTagList != null) { foreach (string queryTag in queryTagList) { StringMemoryItem queryMemoryItem = (StringMemoryItem)ownerAgent.WorkingMemory.GetLastItemByTag(queryTag); if (queryMemoryItem != null) { queryMemoryItemList.Add(queryMemoryItem); } } } // StringMemoryItem queryMemoryItem = null; // if (queryTagList != null) { queryMemoryItem = (StringMemoryItem)ownerAgent.WorkingMemory.GetLastItemByTagList(queryTagList); } // string outputString = patternAction.GetString(ownerAgent.RandomNumberGenerator, queryMemoryItem); string outputString; if (repetitionCount <= maximumRepetitionCount) { if (useVerbatimString) { outputString = outputAction.GetVerbatimString(); } else { outputString = outputAction.GetString(ownerAgent.RandomNumberGenerator, queryMemoryItemList); } if (outputString != null) { if (target == AgentConstants.SPEECH_OUTPUT_TAG) { ownerAgent.SendSpeechOutput(outputString); } else if (target == AgentConstants.FACE_EXPRESSION_OUTPUT_TAG) { ownerAgent.SendExpression(outputString); } else if (target == AgentConstants.INTERNET_OUTPUT_TAG) { ownerAgent.SendInternetRequest(outputString); } } // if (outputString != null) { ownerAgent.SendSpeechOutput(outputString); } // if (expression != null) { ownerAgent.SendExpression(expression); } targetContext = outputAction.TargetContext; targetID = outputAction.TargetID; } else { outputString = ""; targetContext = ""; targetID = ""; } return(true); }
public override Boolean Run(List <object> parameterList, out string targetContext, out string targetID) { Boolean gotWrongRequest = false; Boolean gotNewInput = false; string currOrigin = ""; string currDestination = ""; string currTime = ""; base.Run(parameterList, out targetContext, out targetID); string prefixString = outputAction.GetString(ownerAgent.RandomNumberGenerator, null); MemoryItem norigSought = ItemHandler.PopItem(ownerAgent, AgentConstants.QUERY_TAG_1); MemoryItem ndestSought = ItemHandler.PopItem(ownerAgent, AgentConstants.QUERY_TAG_2); MemoryItem origSought = ItemHandler.PopItem(ownerAgent, AgentConstants.QUERY_TAG_3); MemoryItem destSought = ItemHandler.PopItem(ownerAgent, AgentConstants.QUERY_TAG_4); MemoryItem timeSought = ItemHandler.PopItem(ownerAgent, AgentConstants.QUERY_TAG_5); if (timeSought != null) { currTime = (string)norigSought.GetContent(); } if (norigSought != null) { currOrigin = (string)norigSought.GetContent(); gotNewInput = gotNewInput || (currOrigin != ""); } if (ndestSought != null) { currDestination = (string)ndestSought.GetContent(); gotNewInput = gotNewInput || (currDestination != ""); } if (origSought != null && currOrigin == "") { currOrigin = (string)origSought.GetContent(); gotWrongRequest = gotWrongRequest || (currOrigin == ""); } if (destSought != null && currDestination == "") { currDestination = (string)destSought.GetContent(); gotWrongRequest = gotWrongRequest || (currDestination == ""); } /* * //clears all queries * StringMemoryItem matchMemoryClean = new StringMemoryItem(); * matchMemoryClean.TagList = speechQueries; * matchMemoryClean.SetContent(""); * ownerAgent.WorkingMemory.AddItem(matchMemoryClean); */ //if the user tried to add something, put items back on stack if (gotNewInput) { //puts <Q3> = currOrigin, <Q4> = currDestination, <Q5> = currTime ItemHandler.StoreTermOnTag(ownerAgent, AgentConstants.QUERY_TAG_3, currOrigin); ItemHandler.StoreTermOnTag(ownerAgent, AgentConstants.QUERY_TAG_4, currDestination); ItemHandler.StoreTermOnTag(ownerAgent, AgentConstants.QUERY_TAG_5, currTime); } //If the user did not try to add a value, assume he wants to cancel else { ownerAgent.SendSpeechOutput("Okay then."); targetContext = denyContext; targetID = denyID; return(true); } //User tried to give already given information if (gotWrongRequest) { bool originMissing = (currOrigin == ""); ownerAgent.SendSpeechOutput("I already got your " + (!originMissing ? "origin" : "destination") + " please tell me your " + (originMissing ? "origin." : "destination.")); targetContext = outputAction.TargetContext; targetID = failID; return(true); } targetContext = outputAction.TargetContext; targetID = outputAction.TargetID; return(true); }