Ejemplo n.º 1
0
        //fill this method in with code which will execute
        //once for each cycle of the engine
        public override void Fire()
        {
            Init();  //be sure to leave this here
            if (KB == null)
            {
                Initialize();
            }
            if (KB == null)
            {
                return;
            }
            List <Thing> words = KB.GetChildren(KB.Labeled("Word"));

            foreach (Thing word in words)
            {
                if (KB.Fired(word, KB.immediateMemory))
                {
                    List <Thing> colors = KB.GetChildren(KB.Labeled("Color"));
                    foreach (Thing t in colors)
                    {
                        if (KB.Fired(t, KB.immediateMemory))
                        {
                            word.AdjustReference(t, 1); //Hit
                        }
                        else
                        {
                            word.AdjustReference(t, -1); //Miss
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void CheckForTrainingResult()
        {
            if (actionTrainingState == -1)
            {
                return;
            }
            ModuleUKSN nmUKS = (ModuleUKSN)FindModuleByType(typeof(ModuleUKSN));

            if (nmUKS == null)
            {
                return;
            }
            actionTrainingState--;
            if (actionTrainingState <= 4 || !na.GetNeuronAt("Train").Fired())
            {
                return;
            }
            List <Thing> actions    = nmUKS.GetChildren(nmUKS.Labeled("Action"));
            bool         bResponded = false;

            foreach (Thing action in actions)
            {
                if (nmUKS.Fired(action, 2, false))
                {
                    if (action.Label == trainingCase[1])
                    {
                        SimulatePhrase("good");
                        bResponded = true;
                        break;
                    }
                    else
                    {
                        SimulatePhrase("no");
                        bResponded = true;
                        break;
                    }
                }
            }
            if (bResponded)
            {
                actionTrainingState = 5;
                return;
            }
            ////we "timed out" with no response to the stimulus
            //if (actionTrainingDelay == 4)
            //{
            //    SimulatePhrase("no");
            //}
        }
Ejemplo n.º 3
0
        public override void Fire()
        {
            Init();  //be sure to leave this here
            if (synth == null)
            {
                return;
            }

            if (!na.GetNeuronAt(0).Fired())
            {
                return;
            }

            ModuleUKSN nmKB = (ModuleUKSN)FindModuleByType(typeof(ModuleUKSN));

            if (nmKB == null)
            {
                return;
            }
            List <Thing> words  = nmKB.GetChildren(nmKB.Labeled("Word"));
            bool         paused = true;

            //TODO: replace this direct access into the KB with synapses...then we can eliminate the storage of the words in the things values.
            foreach (Thing word in words)
            {
                if (nmKB.Fired(word, 2, false))
                {
                    paused         = false;
                    phraseToSpeak += " " + word.V.ToString();
                }
            }
            if (paused && phraseToSpeak != "")
            {
                ModuleSpeechIn msi = (ModuleSpeechIn)FindModuleByType(typeof(ModuleSpeechIn));
                if (msi != null)
                {
                    msi.PauseRecognition(); //if there is a recognizer active
                }
                synth.SpeakAsync(phraseToSpeak + ".");
                phraseToSpeak = "";
            }
        }