// Update is called once per frame void Update() { if ((int)(modality & Modality.Linguistic) == 0) { OutputHelper.PrintOutput(Role.Planner, ""); } }
void ChoiceMade(object sender, EventArgs e) { if (gameOver) { return; } string predicate = ((EventManagerArgs)e).EventString.Split('(')[0]; string argument = ((EventManagerArgs)e).EventString.Split('(')[1].Split(',')[0]; if (eventManager.lastParse.Split('(')[0] != predicate) { return; } if (predicate == "lift") { bool winCondition = false; foreach (DictionaryEntry pair in relationTracker.relations) { List <GameObject> objs = (pair.Key as List <GameObject>); if (objs.Count == 2) { if ((objs[0] == GameObject.Find(argument)) && (objs[1] == GameObject.Find("ball"))) { string rel = (pair.Value as string); if (rel.Contains("contain")) { winCondition = true; } } } } if (winCondition) { OutputHelper.PrintOutput(Role.Planner, "You win!"); gameOver = true; } else { OutputHelper.PrintOutput(Role.Planner, "Ha! I win!"); foreach (DictionaryEntry pair in relationTracker.relations) { List <GameObject> objs = (pair.Key as List <GameObject>); if (objs[0] == GameObject.Find("ball")) { string rel = (pair.Value as string); if (rel.Contains("under")) { eventManager.InsertEvent(string.Format("lift({0})", objs[1].name), 0); eventManager.ExecuteNextCommand(); } } } gameOver = true; } } }
// Update is called once per frame void Update() { if (interTargetPositions.Count == 0) { // no queued path if (!Helper.VectorIsNaN(targetPosition)) { // has valid destination if (transform.position != targetPosition) { Vector3 offset = MoveToward(targetPosition); if (offset.sqrMagnitude <= 0.01f) { transform.position = targetPosition; OnAtTarget(this, EventArgs.Empty); } } } else { // cannot execute motion OutputHelper.PrintOutput(Role.Affector, "I'm sorry, I can't do that."); GameObject.Find("BehaviorController").GetComponent <EventManager>().SendMessage("AbortEvent"); targetPosition = transform.position; } } else { // has queued path Vector3 interimTarget = interTargetPositions.Peek(); //Debug.Log (gameObject.name + " " + Helper.VectorToParsable(interimTarget)); if (transform.position != interimTarget) { Vector3 offset = MoveToward(interimTarget); if (offset.sqrMagnitude <= 0.001f) { transform.position = interimTarget; interTargetPositions.Dequeue(); } } } }
void CheckAgreement(bool satisfied) { List <object> diff = GlobalHelper.DiffLists(currentState, relationTracker.relStrings.Cast <object>().ToList()); OnLogEvent(this, new LogEventArgs("Result: " + string.Join(";", diff.Cast <string>().ToArray()))); if (satisfied) { OnLogEvent(this, new LogEventArgs("Response: Agreement")); if ((int)(wilsonState & (WilsonState.ThumbsUp | WilsonState.HeadNod)) == 0) { waitTimer.Enabled = true; wilsonState |= (WilsonState.ThumbsUp | WilsonState.HeadNod); ThumbsUp(); OnLogEvent(this, new LogEventArgs("Wilson: G = " + string.Format(mostRecentGesture))); HeadNod(); OnLogEvent(this, new LogEventArgs("Wilson: G = " + string.Format(mostRecentGesture))); if ((int)(outputModality.modality & OutputModality.Modality.Linguistic) == 1) { OutputHelper.PrintOutput(Role.Planner, "Great!"); OnLogEvent(this, new LogEventArgs("Wilson: S = \"Great!\"")); } } } else { OnLogEvent(this, new LogEventArgs("Response: Disagreement")); if ((int)(wilsonState & WilsonState.HeadShake) == 0) { waitTimer.Enabled = true; wilsonState |= WilsonState.HeadShake; HeadShake(); OnLogEvent(this, new LogEventArgs("Wilson: G = " + string.Format(mostRecentGesture))); if ((int)(outputModality.modality & OutputModality.Modality.Linguistic) == 1) { OutputHelper.PrintOutput(Role.Planner, "That's not quite what I had in mind."); OnLogEvent(this, new LogEventArgs("Wilson: S = \"That's not quite what I had in mind.\"")); goBack = true; } } } moveLogged = true; }
void PrintAndLogLinguisticOutput(string output) { OutputHelper.PrintOutput(Role.Planner, output); OnLogEvent(this, new LogEventArgs(MakeLogString("Wilson: S = ", FormatLogUtterance(output)))); }
// Update is called once per frame void Update() { base.Update(); if (currentStep == ScriptStep.Step0) { if ((int)(wilsonState & WilsonState.Rest) == 0) { waitTimer.Interval = WAIT_TIME + initialLeaderTime; waitTimer.Enabled = true; wilsonState |= (WilsonState.Rest | WilsonState.LookForward); Rest(); LookForward(); OnLogEvent(this, new LogEventArgs("Wilson: G = " + string.Format(mostRecentGesture))); if ((int)(outputModality.modality & OutputModality.Modality.Linguistic) == 1) { OutputHelper.PrintOutput(Role.Planner, "Let's build a pyramid!"); OnLogEvent(this, new LogEventArgs("Wilson: S = \"Let's build a pyramid!\"")); } } } if (currentStep == ScriptStep.Step1A) { currentState = relationTracker.relStrings.Cast <object>().ToList(); goBack = false; if ((int)(wilsonState & WilsonState.Point) == 0) { waitTimer.Enabled = true; wilsonState |= WilsonState.Point; PointAt(GameObject.Find("block1")); OnLogEvent(this, new LogEventArgs("Wilson: G = " + string.Format(mostRecentGesture, "block1"))); if ((int)(outputModality.modality & OutputModality.Modality.Linguistic) == 1) { OutputHelper.PrintOutput(Role.Planner, "Take that block"); OnLogEvent(this, new LogEventArgs("Wilson: S = \"Take that block\"")); } } } if (currentStep == ScriptStep.Step1B) { if ((int)(wilsonState & WilsonState.Point) == 0) { waitTimer.Enabled = true; wilsonState |= WilsonState.Point; PointAt(GameObject.Find("block3")); OnLogEvent(this, new LogEventArgs("Wilson: G = " + string.Format(mostRecentGesture, "block3"))); if ((int)(outputModality.modality & OutputModality.Modality.Linguistic) == 1) { OutputHelper.PrintOutput(Role.Planner, "And that block"); OnLogEvent(this, new LogEventArgs("Wilson: S = \"And that block\"")); } } } if (currentStep == ScriptStep.Step1C) { if ((int)(wilsonState & WilsonState.LookForward) == 0) { wilsonState |= WilsonState.LookForward; LookForward(); OnLogEvent(this, new LogEventArgs("Wilson: G = " + string.Format(mostRecentGesture))); } leftTarget.targetPosition = new Vector3(1.0f, 2.5f, 0.0f); rightTarget.targetPosition = new Vector3(-1.0f, 2.5f, 0.0f); if (leftAtTarget && rightAtTarget) { currentStep = (ScriptStep)((int)currentStep + 1); } } if (currentStep == ScriptStep.Step1D) { if ((int)(wilsonState & WilsonState.PushTogether) == 0) { wilsonState |= WilsonState.PushTogether; PushTogether(); OnLogEvent(this, new LogEventArgs("Wilson: G = " + string.Format(mostRecentGesture))); if ((int)(outputModality.modality & OutputModality.Modality.Linguistic) == 1) { OutputHelper.PrintOutput(Role.Planner, "And put them together"); OnLogEvent(this, new LogEventArgs("Wilson: S = \"And put them together\"")); } } else { bool satisfied = false; foreach (List <GameObject> key in relationTracker.relations.Keys) { if (key.SequenceEqual(new List <GameObject>(new GameObject[] { GameObject.Find("block1"), GameObject.Find("block3") }))) { string[] relations = relationTracker.relations[key].ToString().Split(','); if (relations.Contains("right") && relations.Contains("touching")) { satisfied = true; break; } } } if (humanMoveComplete) { List <object> diff = GlobalHelper.DiffLists(currentState, relationTracker.relStrings.Cast <object>().ToList()); OnLogEvent(this, new LogEventArgs("Result: " + string.Join(";", diff.Cast <string>().ToArray()))); if (satisfied) { OnLogEvent(this, new LogEventArgs("Wilson: Resp = Agreement")); if ((int)(wilsonState & (WilsonState.ThumbsUp | WilsonState.HeadNod)) == 0) { waitTimer.Enabled = true; wilsonState |= (WilsonState.ThumbsUp | WilsonState.HeadNod); ThumbsUp(); OnLogEvent(this, new LogEventArgs("Wilson: G = " + string.Format(mostRecentGesture))); HeadNod(); OnLogEvent(this, new LogEventArgs("Wilson: G = " + string.Format(mostRecentGesture))); if ((int)(outputModality.modality & OutputModality.Modality.Linguistic) == 1) { OutputHelper.PrintOutput(Role.Planner, "Great!"); OnLogEvent(this, new LogEventArgs("Wilson: S = \"Great!\"")); } } } else { OnLogEvent(this, new LogEventArgs("Wilson: Resp = Disgreement")); if ((int)(wilsonState & WilsonState.HeadShake) == 0) { waitTimer.Enabled = true; wilsonState |= WilsonState.HeadShake; HeadShake(); OnLogEvent(this, new LogEventArgs("Wilson: G = " + string.Format(mostRecentGesture))); if ((int)(outputModality.modality & OutputModality.Modality.Linguistic) == 1) { OutputHelper.PrintOutput(Role.Planner, "That's not quite what I had in mind."); OnLogEvent(this, new LogEventArgs("Wilson: S = \"That's not quite what I had in mind.\"")); goBack = true; } } } moveLogged = true; } } } if (currentStep == ScriptStep.Step2A) { currentState = relationTracker.relStrings.Cast <object>().ToList(); goBack = false; if ((int)(wilsonState & WilsonState.Point) == 0) { waitTimer.Enabled = true; wilsonState |= WilsonState.Point; PointAt(GameObject.Find("block2")); OnLogEvent(this, new LogEventArgs("Wilson: G = " + string.Format(mostRecentGesture, "block2"))); if ((int)(outputModality.modality & OutputModality.Modality.Linguistic) == 1) { OutputHelper.PrintOutput(Role.Planner, "Take that block"); OnLogEvent(this, new LogEventArgs("Wilson: S = \"Take that block\"")); } } } if (currentStep == ScriptStep.Step2B) { if ((int)(wilsonState & WilsonState.Point) == 0) { waitTimer.Enabled = true; wilsonState |= WilsonState.Point; PointAt(GameObject.Find("block3")); OnLogEvent(this, new LogEventArgs("Wilson: G = " + string.Format(mostRecentGesture, "block3"))); if ((int)(outputModality.modality & OutputModality.Modality.Linguistic) == 1) { OutputHelper.PrintOutput(Role.Planner, "And that block"); OnLogEvent(this, new LogEventArgs("Wilson: S = \"And that block\"")); } } } if (currentStep == ScriptStep.Step2C) { if ((int)(wilsonState & WilsonState.LookForward) == 0) { wilsonState |= WilsonState.LookForward; LookForward(); OnLogEvent(this, new LogEventArgs("Wilson: G = " + string.Format(mostRecentGesture))); } leftTarget.targetPosition = new Vector3(1.0f, 2.5f, 0.0f); rightTarget.targetPosition = new Vector3(-1.0f, 2.5f, 0.0f); if (leftAtTarget && rightAtTarget) { currentStep = (ScriptStep)((int)currentStep + 1); } } if (currentStep == ScriptStep.Step2D) { if ((int)(wilsonState & WilsonState.PushTogether) == 0) { wilsonState |= WilsonState.PushTogether; PushTogether(); OnLogEvent(this, new LogEventArgs("Wilson: G = " + string.Format(mostRecentGesture))); if ((int)(outputModality.modality & OutputModality.Modality.Linguistic) == 1) { OutputHelper.PrintOutput(Role.Planner, "And put them together"); OnLogEvent(this, new LogEventArgs("Wilson: S = \"And put them together\"")); } } else { bool satisfied = false; foreach (List <GameObject> key in relationTracker.relations.Keys) { if (key.SequenceEqual(new List <GameObject>(new GameObject[] { GameObject.Find("block2"), GameObject.Find("block3") }))) { string[] relations = relationTracker.relations[key].ToString().Split(','); if (relations.Contains("left") && relations.Contains("touching")) { satisfied = true; break; } } } if (humanMoveComplete) { List <object> diff = GlobalHelper.DiffLists(currentState, relationTracker.relStrings.Cast <object>().ToList()); OnLogEvent(this, new LogEventArgs("Result: " + string.Join(";", diff.Cast <string>().ToArray()))); if (satisfied) { OnLogEvent(this, new LogEventArgs("Wilson: Resp = Agreement")); if ((int)(wilsonState & (WilsonState.ThumbsUp | WilsonState.HeadNod)) == 0) { waitTimer.Enabled = true; wilsonState |= (WilsonState.ThumbsUp | WilsonState.HeadNod); ThumbsUp(); OnLogEvent(this, new LogEventArgs("Wilson: G = " + string.Format(mostRecentGesture))); HeadNod(); OnLogEvent(this, new LogEventArgs("Wilson: G = " + string.Format(mostRecentGesture))); if ((int)(outputModality.modality & OutputModality.Modality.Linguistic) == 1) { OutputHelper.PrintOutput(Role.Planner, "Great!"); OnLogEvent(this, new LogEventArgs("Wilson: S = \"Great!\"")); } } } else { OnLogEvent(this, new LogEventArgs("Wilson: Resp = Disagreement")); if ((int)(wilsonState & WilsonState.HeadShake) == 0) { waitTimer.Enabled = true; wilsonState |= WilsonState.HeadShake; HeadShake(); OnLogEvent(this, new LogEventArgs("Wilson: G = " + string.Format(mostRecentGesture))); if ((int)(outputModality.modality & OutputModality.Modality.Linguistic) == 1) { OutputHelper.PrintOutput(Role.Planner, "That's not quite what I had in mind."); OnLogEvent(this, new LogEventArgs("Wilson: S = \"That's not quite what I had in mind.\"")); goBack = true; } } } } moveLogged = true; } } if (currentStep == ScriptStep.Step3A) { currentState = relationTracker.relStrings.Cast <object>().ToList(); goBack = false; if ((int)(wilsonState & WilsonState.Point) == 0) { waitTimer.Enabled = true; wilsonState |= WilsonState.Point; PointAt(GameObject.Find("block4")); OnLogEvent(this, new LogEventArgs("Wilson: G = " + string.Format(mostRecentGesture, "block4"))); if ((int)(outputModality.modality & OutputModality.Modality.Linguistic) == 1) { OutputHelper.PrintOutput(Role.Planner, "Take that block"); OnLogEvent(this, new LogEventArgs("Wilson: S = \"Take that block\"")); } } } if (currentStep == ScriptStep.Step3B) { if ((int)(wilsonState & WilsonState.Point) == 0) { waitTimer.Enabled = true; wilsonState |= WilsonState.Point; PointAt(GameObject.Find("block3")); OnLogEvent(this, new LogEventArgs("Wilson: G = " + string.Format(mostRecentGesture, "block3"))); if ((int)(outputModality.modality & OutputModality.Modality.Linguistic) == 1) { OutputHelper.PrintOutput(Role.Planner, "And put it behind that block"); OnLogEvent(this, new LogEventArgs("Wilson: S = \"And put it behind that block\"")); } } } if (currentStep == ScriptStep.Step3C) { if ((int)(wilsonState & WilsonState.Claw) == 0) { wilsonState |= (WilsonState.Claw | WilsonState.LookForward); Claw(GameObject.Find("block4").transform.position, GameObject.Find("block3").transform.position - (Vector3.forward * 0.5f)); OnLogEvent(this, new LogEventArgs( "Wilson: G = " + string.Format(mostRecentGesture, "behind(block3, Persp = Wilson)"))); LookForward(); OnLogEvent(this, new LogEventArgs("Wilson: G = " + string.Format(mostRecentGesture))); } else { bool satisfied = false; foreach (List <GameObject> key in relationTracker.relations.Keys) { if (key.SequenceEqual(new List <GameObject>(new GameObject[] { GameObject.Find("block4"), GameObject.Find("block3") }))) { string[] relations = relationTracker.relations[key].ToString().Split(','); if (relations.Contains("in_front")) { satisfied = true; break; } } } if (humanMoveComplete) { List <object> diff = GlobalHelper.DiffLists(currentState, relationTracker.relStrings.Cast <object>().ToList()); OnLogEvent(this, new LogEventArgs("Result: " + string.Join(";", diff.Cast <string>().ToArray()))); if (satisfied) { OnLogEvent(this, new LogEventArgs("Wilson: Resp = Agreement")); if ((int)(wilsonState & (WilsonState.ThumbsUp | WilsonState.HeadNod)) == 0) { waitTimer.Enabled = true; wilsonState |= (WilsonState.ThumbsUp | WilsonState.HeadNod); ThumbsUp(); OnLogEvent(this, new LogEventArgs("Wilson: G = " + string.Format(mostRecentGesture))); HeadNod(); OnLogEvent(this, new LogEventArgs("Wilson: G = " + string.Format(mostRecentGesture))); if ((int)(outputModality.modality & OutputModality.Modality.Linguistic) == 1) { OutputHelper.PrintOutput(Role.Planner, "Great!"); OnLogEvent(this, new LogEventArgs("Wilson: S = \"Great!\"")); } } } else { OnLogEvent(this, new LogEventArgs("Wilson: Resp = Disagreement")); if ((int)(wilsonState & WilsonState.HeadShake) == 0) { waitTimer.Enabled = true; wilsonState |= WilsonState.HeadShake; HeadShake(); OnLogEvent(this, new LogEventArgs("Wilson: G = " + string.Format(mostRecentGesture))); if ((int)(outputModality.modality & OutputModality.Modality.Linguistic) == 1) { OutputHelper.PrintOutput(Role.Planner, "That's not quite what I had in mind."); OnLogEvent(this, new LogEventArgs("Wilson: S = \"That's not quite what I had in mind.\"")); goBack = true; } } } moveLogged = true; } } } if (currentStep == ScriptStep.Step4A) { currentState = relationTracker.relStrings.Cast <object>().ToList(); goBack = false; if ((int)(wilsonState & WilsonState.Point) == 0) { waitTimer.Enabled = true; wilsonState |= WilsonState.Point; PointAt(GameObject.Find("block5")); OnLogEvent(this, new LogEventArgs("Wilson: G = " + string.Format(mostRecentGesture, "block5"))); if ((int)(outputModality.modality & OutputModality.Modality.Linguistic) == 1) { OutputHelper.PrintOutput(Role.Planner, "Take that block"); OnLogEvent(this, new LogEventArgs("Wilson: S = \"Take that block\"")); } } } if (currentStep == ScriptStep.Step4B) { if ((int)(wilsonState & WilsonState.Point) == 0) { waitTimer.Enabled = true; wilsonState |= WilsonState.Point; PointAt(GameObject.Find("block3")); OnLogEvent(this, new LogEventArgs("Wilson: G = " + string.Format(mostRecentGesture, "block3"))); if ((int)(outputModality.modality & OutputModality.Modality.Linguistic) == 1) { OutputHelper.PrintOutput(Role.Planner, "And put it in front of that block"); OnLogEvent(this, new LogEventArgs("Wilson: S = \"And put it in front of that block\"")); } } } if (currentStep == ScriptStep.Step4C) { if ((int)(wilsonState & WilsonState.Claw) == 0) { wilsonState |= (WilsonState.Claw | WilsonState.LookForward); Claw(GameObject.Find("block5").transform.position, GameObject.Find("block3").transform.position + Vector3.forward); OnLogEvent(this, new LogEventArgs("Wilson: G = " + string.Format(mostRecentGesture, "in_front(block3, Persp = Wilson)"))); LookForward(); OnLogEvent(this, new LogEventArgs("Wilson: G = " + string.Format(mostRecentGesture))); } else { bool satisfied = false; foreach (List <GameObject> key in relationTracker.relations.Keys) { if (key.SequenceEqual(new List <GameObject>(new GameObject[] { GameObject.Find("block5"), GameObject.Find("block3") }))) { string[] relations = relationTracker.relations[key].ToString().Split(','); if (relations.Contains("behind")) { satisfied = true; break; } } } if (humanMoveComplete) { List <object> diff = GlobalHelper.DiffLists(currentState, relationTracker.relStrings.Cast <object>().ToList()); OnLogEvent(this, new LogEventArgs("Result: " + string.Join(";", diff.Cast <string>().ToArray()))); if (satisfied) { OnLogEvent(this, new LogEventArgs("Response: Agreement")); if ((int)(wilsonState & (WilsonState.ThumbsUp | WilsonState.HeadNod)) == 0) { waitTimer.Enabled = true; wilsonState |= (WilsonState.ThumbsUp | WilsonState.HeadNod); ThumbsUp(); OnLogEvent(this, new LogEventArgs("Wilson: G = " + string.Format(mostRecentGesture))); HeadNod(); OnLogEvent(this, new LogEventArgs("Wilson: G = " + string.Format(mostRecentGesture))); if ((int)(outputModality.modality & OutputModality.Modality.Linguistic) == 1) { OutputHelper.PrintOutput(Role.Planner, "Great!"); OnLogEvent(this, new LogEventArgs("Wilson: S = \"Great!\"")); } } } else { OnLogEvent(this, new LogEventArgs("Response: Disagreement")); if ((int)(wilsonState & WilsonState.HeadShake) == 0) { waitTimer.Enabled = true; wilsonState |= WilsonState.HeadShake; HeadShake(); OnLogEvent(this, new LogEventArgs("Wilson: G = " + string.Format(mostRecentGesture))); if ((int)(outputModality.modality & OutputModality.Modality.Linguistic) == 1) { OutputHelper.PrintOutput(Role.Planner, "That's not quite what I had in mind."); OnLogEvent(this, new LogEventArgs("Wilson: S = \"That's not quite what I had in mind.\"")); goBack = true; } } } moveLogged = true; } } } if (currentStep == ScriptStep.Step5A) { currentState = relationTracker.relStrings.Cast <object>().ToList(); goBack = false; if ((int)(wilsonState & WilsonState.Point) == 0) { waitTimer.Enabled = true; wilsonState |= WilsonState.Point; PointAt(GameObject.Find("block6")); OnLogEvent(this, new LogEventArgs("Wilson: G = " + string.Format(mostRecentGesture, "block6"))); if ((int)(outputModality.modality & OutputModality.Modality.Linguistic) == 1) { OutputHelper.PrintOutput(Role.Planner, "Take that block"); OnLogEvent(this, new LogEventArgs("Wilson: S = \"Take that block\"")); } } } if (currentStep == ScriptStep.Step5B) { if ((int)(wilsonState & WilsonState.Point) == 0) { waitTimer.Enabled = true; wilsonState |= WilsonState.Point; PointAt(GameObject.Find("block3")); OnLogEvent(this, new LogEventArgs("Wilson: G = " + string.Format(mostRecentGesture, "block3"))); if ((int)(outputModality.modality & OutputModality.Modality.Linguistic) == 1) { OutputHelper.PrintOutput(Role.Planner, "And put it on that block"); OnLogEvent(this, new LogEventArgs("Wilson: S = \"And put it on that block\"")); } } } if (currentStep == ScriptStep.Step5C) { if ((int)(wilsonState & WilsonState.Claw) == 0) { wilsonState |= (WilsonState.Claw | WilsonState.LookForward); Claw(GameObject.Find("block6").transform.position, GameObject.Find("block3").transform.position); OnLogEvent(this, new LogEventArgs("Wilson: G = " + string.Format(mostRecentGesture, "block3"))); LookForward(); OnLogEvent(this, new LogEventArgs("Wilson: G = " + string.Format(mostRecentGesture))); } else { bool satisfied = false; foreach (List <GameObject> key in relationTracker.relations.Keys) { if (key.SequenceEqual(new List <GameObject>(new GameObject[] { GameObject.Find("block3"), GameObject.Find("block6") }))) { string[] relations = relationTracker.relations[key].ToString().Split(','); if (relations.Contains("support")) { satisfied = true; break; } } } if (humanMoveComplete) { List <object> diff = GlobalHelper.DiffLists(currentState, relationTracker.relStrings.Cast <object>().ToList()); OnLogEvent(this, new LogEventArgs("Result: " + string.Join(";", diff.Cast <string>().ToArray()))); if (satisfied) { OnLogEvent(this, new LogEventArgs("Response: Agreement")); if ((int)(wilsonState & (WilsonState.ThumbsUp | WilsonState.HeadNod)) == 0) { waitTimer.Enabled = true; wilsonState |= (WilsonState.ThumbsUp | WilsonState.HeadNod); ThumbsUp(); OnLogEvent(this, new LogEventArgs("Wilson: G = " + string.Format(mostRecentGesture))); HeadNod(); OnLogEvent(this, new LogEventArgs("Wilson: G = " + string.Format(mostRecentGesture))); if ((int)(outputModality.modality & OutputModality.Modality.Linguistic) == 1) { OutputHelper.PrintOutput(Role.Planner, "Great!"); OnLogEvent(this, new LogEventArgs("Wilson: S = \"Great!\"")); } } } else { OnLogEvent(this, new LogEventArgs("Response: Disagreement")); if ((int)(wilsonState & WilsonState.HeadShake) == 0) { waitTimer.Enabled = true; wilsonState |= WilsonState.HeadShake; HeadShake(); OnLogEvent(this, new LogEventArgs("Wilson: G = " + string.Format(mostRecentGesture))); if ((int)(outputModality.modality & OutputModality.Modality.Linguistic) == 1) { OutputHelper.PrintOutput(Role.Planner, "That's not quite what I had in mind."); OnLogEvent(this, new LogEventArgs("Wilson: S = \"That's not quite what I had in mind.\"")); goBack = true; } } } moveLogged = true; } } } if (currentStep == ScriptStep.Step6) { if ((int)(wilsonState & WilsonState.Rest) == 0) { wilsonState |= WilsonState.Rest; Rest(); if ((int)(outputModality.modality & OutputModality.Modality.Linguistic) == 1) { OutputHelper.PrintOutput(Role.Planner, "OK, we're done!"); OnLogEvent(this, new LogEventArgs("Wilson: S = \"OK, we're done!\"")); } CloseLog(); } } /*if (Input.GetKeyDown (KeyCode.Space)) { * wilsonState = 0; * currentStep = (DemoStep)((int)currentStep + 1); * }*/ }
private void UnknownSeen(Voxeme voxeme) { string color = voxeme.voxml.Attributes.Attrs[0].Value; // just grab the first one for now OutputHelper.PrintOutput(Role.Affector, string.Format("I didn't know that {0} block was there!", color)); }
private void KnownUnseen(Voxeme voxeme) { string color = voxeme.voxml.Attributes.Attrs[0].Value; // just grab the first one for now OutputHelper.PrintOutput(Role.Affector, string.Format("Holy cow! What happened to the {0} block?", color)); }
public void MessageReceived(String inputString) { Regex r = new Regex(@".*\(.*\)"); Regex v = new Regex("<.*?;.*?;.*?>"); string functionalCommand = ""; if (inputString != "") { InputEventArgs inputArgs = new InputEventArgs(inputString); OnInputReceived(this, inputArgs); Debug.Log("User entered: " + inputString); Dictionary <string, string> vectors = new Dictionary <string, string>(); foreach (Match match in v.Matches(inputString)) { vectors.Add(string.Format("V@{0}", match.Index), match.Value); Debug.Log(string.Format("{0}:{1}", string.Format("V@{0}", match.Index), match.Value)); inputString = v.Replace(inputString, string.Format("V@{0}", match.Index), 1); } Debug.Log(inputString); if (!r.IsMatch(inputString)) { // is not already functional form // parse into functional form String[] inputs = inputString.Split(new char[] { '.', ',', '!' }); List <String> commands = new List <String>(); foreach (String s in inputs) { if (s != String.Empty) { commands.Add(commBridge.NLParse(s.Trim().ToLower())); } } functionalCommand = String.Join(";", commands.ToArray()); } else { functionalCommand = inputString; } Debug.Log(functionalCommand); if (functionalCommand.Count(x => x == '(') == functionalCommand.Count(x => x == ')')) { //eventManager.ClearEvents (); if (macros != null) { foreach (KeyValuePair <String, String> kv in macros.commandMacros) { // if input is a macro if (functionalCommand == kv.Key) { // sub in value functionalCommand = kv.Value; break; } } } Debug.Log("Parsed as: " + functionalCommand); InputEventArgs parseArgs = new InputEventArgs(functionalCommand); OnParseComplete(this, parseArgs); if (!silenceAcknowledgment) { OutputHelper.PrintOutput(Role.Affector, "OK."); OutputHelper.PrintOutput(Role.Planner, ""); } Debug.Log(functionalCommand); commands = functionalCommand.Split(';'); foreach (String commandString in commands) { string command = commandString; foreach (string vector in vectors.Keys) { command = command.Replace(vector, vectors[vector]); } // add to queue eventManager.QueueEvent(command); } if (eventManager.immediateExecution) { eventManager.ExecuteNextCommand(); } } } }