Example #1
0
        public void SubmitResult(ChoreographyCue cue)
        {
            var result = new Message(MsgType.Notify, $"{RESPONSE}{NEXT}{cue}");

            Log.Debug(_tag, $"Sending submission: {result.Content}");
            Opponent.SendMessage(result);
        }
Example #2
0
        public async void SubmitResult(ChoreographyCue cue)
        {
            Log.Debug(_tag, "Waiting for opponent submission signal.");
            await opponentSubmissionSignal.WaitAsync();

            Log.Debug(_tag, "Opponent submission received.");

            if (double.IsNaN(cue.Score))
            {
                Speech.Say("Gesture unrecognized."); cue.Score = double.NegativeInfinity;
            }
            else if (double.IsNaN(opponentSubmittedCue.Score))
            {
                Opponent.SendMessage(MsgType.PushSpeech, "Gesture unrecognized."); opponentSubmittedCue.Score = double.NegativeInfinity;
            }
            else
            {
                var ownNetScore = cue.Score - cue.Delay.TotalSeconds;
                var oppNetScore = opponentSubmittedCue.Score - opponentSubmittedCue.Delay.TotalSeconds;
                if (Math.Abs(ownNetScore - oppNetScore) < 0.35)
                {
                    Speech.Say("Tie."); Opponent.SendMessage(MsgType.PushSpeech, "Tie.");
                }
                else if (ownNetScore > oppNetScore)
                {
                    Speech.Say("Point.");
                }
                else
                {
                    Opponent.SendMessage(MsgType.PushSpeech, "Point.");
                }
            }

            Generator.SubmitResults(cue, opponentSubmittedCue);
        }
Example #3
0
        public void SubmitResult(ChoreographyCue cue)
        {
            //if (double.IsNaN(cue.Score))
            //{
            //    Speech.Say("What the heck was that?");
            //}
            //else if (cue.Score < 0)
            //{
            //    var recognizedAsName = Classifiers[cue.ClassifierKey].MatchingDatasetClasses[cue.GestureClassIndex].className;
            //    Speech.Say($"Looked more like {recognizedAsName}, with {(-1 * cue.Score):f1} points.", SoundOptions.AtSpeed(2.0));
            //}
            //else
            //{
            //    Speech.Say($"Score {cue.Score:f1}, {cue.Delay.TotalSeconds:f1} seconds", SoundOptions.AtSpeed(2.0));
            //}

            if (IsOnPlayerTwo)
            {
                if (double.IsNaN(PlayerOneCue.Score))
                {
                    Speech.Say("First gesture unrecognized.", SoundOptions.AtSpeed(2.0));
                }
                else if (double.IsNaN(cue.Score))
                {
                    Speech.Say("Second gesture unrecognized.", SoundOptions.AtSpeed(2.0));
                }
                else
                {
                    var P1netscore = PlayerOneCue.Score - PlayerOneCue.Delay.TotalSeconds;
                    var P2netscore = cue.Score - cue.Delay.TotalSeconds;
                    if (Math.Abs(P1netscore - P2netscore) < 0.35)
                    {
                        Speech.Say("Tie.");
                    }
                    else if (P1netscore > P2netscore)
                    {
                        Speech.Say("Point to first.", SoundOptions.AtSpeed(2.0));
                    }
                    else
                    {
                        Speech.Say("Point to second.", SoundOptions.AtSpeed(2.0));
                    }
                }

                Generator.SubmitResults(PlayerOneCue, cue);
                IsOnPlayerTwo = false;
                PlayerOneCue  = null;
            }
            else
            {
                PlayerOneCue  = cue;
                IsOnPlayerTwo = true;
                ReceivedSubmission.Set();
            }
        }
Example #4
0
        public void HandleMessage(object sender, EventArgs <Message> messageArgs)
        {
            var message = messageArgs.Value;

            if (message.Type != MsgType.Notify || !message.Content.StartsWith(PROMPT))
            {
                Log.Debug(_tag, $"Handling malformed message: {message.Type} | {message.Content}");
                return;
            }

            Log.Debug(_tag, $"Parsing cue prompt message: {message.Type} | {message.Content}");
            var cuestring = message.Content.Split(onNEXT, 2)[1];
            var cue       = ChoreographyCue.Parse(cuestring);

            OnPromptCue.Raise(cue);
        }
Example #5
0
        public void HandleResponse(object sender, EventArgs <Message> messageArgs)
        {
            var message = messageArgs.Value;

            if (message.Type != MsgType.Notify || !message.Content.StartsWith(RESPONSE))
            {
                Log.Debug(_tag, $"Parsing malformed message: {message.Type} | {message.Content}");
                return;
            }

            Log.Debug(_tag, $"Parsing opponent's response message: {message.Type} | {message.Content}");
            var cuestring = message.Content.Split(onNEXT, 2)[1];
            var cue       = ChoreographyCue.Parse(cuestring);

            opponentSubmittedCue = cue;
            opponentSubmissionSignal.Set();
        }
Example #6
0
 public void SubmitResult(ChoreographyCue cue)
 {
     if (double.IsNaN(cue.Score))
     {
         Speech.Say("What the heck was that?");
     }
     else if (cue.Score < 0) // Encodes "score but for the wrong gesture" in our Cue.Score scheme.
     {
         var recognizedAsName = Classifiers[cue.ClassifierKey].MatchingDatasetClasses[cue.GestureClassIndex].className;
         Speech.Say($"Looked more like {recognizedAsName}, with {(-1 * cue.Score):f1} points.", SoundOptions.AtSpeed(2.0));
     }
     else
     {
         Speech.Say($"Score {cue.Score:f1}, {cue.Delay.TotalSeconds:f1} seconds", SoundOptions.AtSpeed(2.0));
     }
     Generator.SubmitResults(cue, default(ChoreographyCue));
 }