// This function takes whether this step has been answered (current answer) and the current answer key // Retrieves the 'answer pattern' associated with that answer key // and calculates the new pattern based on whether the step was answered. Returns the key associated with this pattern public static int CalculateNewAnswerKey(int currentanswer, int answerkey, int step) { string currentpattern = SQLAnswerPattern.GetAnswerPattern(answerkey)[1]; int newAnswerKey = 0; StringBuilder sb = new StringBuilder(currentpattern); char[] ca = currentanswer.ToString().ToCharArray(); sb[step] = ca[0]; currentpattern = sb.ToString(); newAnswerKey = SQLAnswerPattern.GetAnswerKey(currentpattern); return(newAnswerKey); }
// Text-based function - needs to be modified public static Tuple <string, int, string> NicoResponseText(string path, List <int> problemStep, int speakerSpoke, string transcript, DateTime time, string page, string userID, string useraudio) { Tuple <string, int, string> response = new Tuple <string, int, string>("", 1, "no answer"); bool checkIfAnswered = false; bool agent = SQLAgent.GetAgentSetting(userID); try { // ****** IMPORTANT ****** // These variables might change based on which NaoNRIProgram calling string verbalManagerFile = (agent) ? Globals.pythonDirectory() + "NaoNRIPrograms\\VerbalManager\\DialogueManager_Agent.py " : Globals.pythonDirectory() + "NaoNRIPrograms\\VerbalManager\\DialogueManager.py "; string condition = SQLConditionGenderInfo.GetCondition(userID); string robotIP = SQLConditionGenderInfo.GetRobotIP(userID); string enttype = SQLConditionGenderInfo.GetEntrainment(userID); // Get whether the current step has been answered and pass that along int currentstep = problemStep[1]; int answerKey = problemStep[3]; int numturns = problemStep[6]; string answerPattern = SQLAnswerPattern.GetAnswerPattern(answerKey, userID)[1]; char[] chAnswerPattern = answerPattern.ToCharArray(); if (page == "ProblemPage") { if (transcript == "" || transcript == null) // Need to handle when there is no transcript - will depend on if this is the first time we've been here or not { //transcript = problemStep[0].ToString() + "_" + problemStep[1].ToString(); transcript = "no response"; response = dialogueManager(userID, path, problemStep, speakerSpoke, transcript, time, checkIfAnswered, condition); // Generate Nico's response (currently just pandorbots) //moveSpeak(path, response.Item1, response.Item2, verbalManagerFile, useraudio, condition, userID, time, numturns, robotIP, enttype, agent); } else if (transcript == "next step") { if (chAnswerPattern[currentstep] == '1') { transcript = transcript + " " + problemStep[0].ToString() + " " + problemStep[1].ToString() + " a"; } else { transcript = transcript + " " + problemStep[0].ToString() + " " + problemStep[1].ToString(); } response = dialogueManager(userID, path, problemStep, speakerSpoke, transcript, time, checkIfAnswered, condition); // Generate Nico's response (currently just pandorbots) //moveSpeak(path, response.Item1, response.Item2, verbalManagerFile, useraudio, condition, userID, time, 0, robotIP, enttype, agent); } else if (transcript == "prior step") { if (chAnswerPattern[currentstep] == '1') { transcript = transcript + " " + problemStep[0].ToString() + " " + problemStep[1].ToString() + " a"; } else { transcript = transcript + " " + problemStep[0].ToString() + " " + problemStep[1].ToString(); } response = dialogueManager(userID, path, problemStep, speakerSpoke, transcript, time, checkIfAnswered, condition); // Generate Nico's response (currently just pandorbots) //moveSpeak(path, response.Item1, response.Item2, verbalManagerFile, useraudio, condition, userID, time, 0, robotIP, enttype, agent); } else if (transcript == "problem start") { transcript = transcript + " " + problemStep[0].ToString(); response = dialogueManager(userID, path, problemStep, speakerSpoke, transcript, time, checkIfAnswered, condition); // Generate Nico's response (currently just pandorbots) //moveSpeak(path, response.Item1, response.Item2, verbalManagerFile, useraudio, condition, userID, time, 0, robotIP, enttype, agent); } else { // make sure topic set to the correct problem and step // detect problem and step we're on, set to that problem and step // don't play response checkIfAnswered = true; // now generate response response = dialogueManager(userID, path, problemStep, speakerSpoke, transcript, time, checkIfAnswered, condition); // Generate Nico's response (currently just pandorbots) //moveSpeak(path, response.Item1, response.Item2, verbalManagerFile, useraudio, condition, userID, time, numturns, robotIP, enttype, agent); } } else if (page == "HelloNico") { response = dialogueManager(userID, path, problemStep, speakerSpoke, transcript, time, checkIfAnswered, condition); // Generate Nico's response (currently just pandorbots) //moveSpeak(path, response.Item1, response.Item2, verbalManagerFile, useraudio, condition, userID, time, numturns, robotIP, enttype, agent); } else { SQLLog.InsertLog(DateTime.Now, "problem with page detection", "page string not being filled in", "ResponseGeneration.NicoResponse", 1); } } catch (Exception error) { SQLLog.InsertLog(DateTime.Now, error.Message, error.StackTrace, "ResponseGeneration.NicoResponse", 1); } return(response); }
/* Using speaker info, get Nico's response and instigate movement * Returns a tuple containing the path to the file of Nico's response, Nico's movement code, and whether Nico provided the answer to this step */ public static Tuple <string, int, string> NicoResponse(string path, List <int> problemStep, int speakerSpoke, string transcript, DateTime time, string page, string userID, string useraudio) { Tuple <string, int, string> nicoResponse = new Tuple <string, int, string>("", 1, "no answer"); bool checkIfAnswered = false; try { // ****** IMPORTANT ****** // These variables might change based on which NaoNRIProgram calling // File options: C:\\Python27\\NaoNRIPrograms\\VerbalManager\\simpleGestureSelectionForAutomatedSys.py // C:\\Python27\\NaoNRIPrograms\\VerbalManager\\nonVerbalManager.py string verbalManagerFile = "C:\\Python27\\NaoNRIPrograms\\VerbalManager\\nonVerbalManager.py "; string condition = "entrain"; // Get whether the current step has been answered and pass that along int currentstep = problemStep[1]; int answerKey = problemStep[3]; int numturns = problemStep[6]; string answerPattern = SQLAnswerPattern.GetAnswerPattern(answerKey)[1]; char[] chAnswerPattern = answerPattern.ToCharArray(); if (page == "ProblemPage") { if (transcript == "" || transcript == null) // Need to handle when there is no transcript - will depend on if this is the first time we've been here or not { //transcript = problemStep[0].ToString() + "_" + problemStep[1].ToString(); transcript = "no response"; nicoResponse = dialogueManager(path, problemStep, speakerSpoke, transcript, time, checkIfAnswered, condition); // Generate Nico's response (currently just pandorbots) nicoMoveSpeak(nicoResponse.Item1, nicoResponse.Item2, verbalManagerFile, useraudio, condition, userID, time, numturns); } else if (transcript == "next step") { if (chAnswerPattern[currentstep + 1] == '1') { transcript = transcript + " " + problemStep[0].ToString() + " " + problemStep[1].ToString() + " a"; } else { transcript = transcript + " " + problemStep[0].ToString() + " " + problemStep[1].ToString(); } nicoResponse = dialogueManager(path, problemStep, speakerSpoke, transcript, time, checkIfAnswered, condition); // Generate Nico's response (currently just pandorbots) nicoMoveSpeak(nicoResponse.Item1, nicoResponse.Item2, verbalManagerFile, useraudio, condition, userID, time, numturns); } else if (transcript == "prior step") { if (chAnswerPattern[currentstep - 1] == '1') { transcript = transcript + " " + problemStep[0].ToString() + " " + problemStep[1].ToString() + " a"; } else { transcript = transcript + " " + problemStep[0].ToString() + " " + problemStep[1].ToString(); } nicoResponse = dialogueManager(path, problemStep, speakerSpoke, transcript, time, checkIfAnswered, condition); // Generate Nico's response (currently just pandorbots) nicoMoveSpeak(nicoResponse.Item1, nicoResponse.Item2, verbalManagerFile, useraudio, condition, userID, time, numturns); } else if (transcript == "problem start") { transcript = transcript + " " + problemStep[0].ToString(); nicoResponse = dialogueManager(path, problemStep, speakerSpoke, transcript, time, checkIfAnswered, condition); // Generate Nico's response (currently just pandorbots) nicoMoveSpeak(nicoResponse.Item1, nicoResponse.Item2, verbalManagerFile, useraudio, condition, userID, time, numturns); } else { // make sure topic set to the correct problem and step // detect problem and step we're on, set to that problem and step // don't play response checkIfAnswered = true; // now generate response nicoResponse = dialogueManager(path, problemStep, speakerSpoke, transcript, time, checkIfAnswered, condition); // Generate Nico's response (currently just pandorbots) nicoMoveSpeak(nicoResponse.Item1, nicoResponse.Item2, verbalManagerFile, useraudio, condition, userID, time, numturns); } } else if (page == "HelloNico") { nicoResponse = dialogueManager(path, problemStep, speakerSpoke, transcript, time, checkIfAnswered, condition); // Generate Nico's response (currently just pandorbots) nicoMoveSpeak(nicoResponse.Item1, nicoResponse.Item2, verbalManagerFile, useraudio, condition, userID, time, numturns); } else { SQLLog.InsertLog(DateTime.Now, "problem with page detection", "page string not being filled in", "ResponseGeneration.NicoResponse", 1); } } catch (Exception error) { SQLLog.InsertLog(DateTime.Now, error.Message, error.StackTrace, "ResponseGeneration.NicoResponse", 1); } return(nicoResponse); }