Esempio n. 1
0
        //fill this method in with code which will execute once
        //when the module is added, when "initialize" is selected from the context menu,
        //or when the engine restart button is pressed
        public override void Initialize()
        {
            base.Initialize();
            foreach (Neuron n in na.Neurons())
            {
                n.DeleteAllSynapes();
            }
            ModuleView na1 = theNeuronArray.FindAreaByLabel("KBOut");

            if (na1 != null)
            {
                foreach (Neuron n in na1.Neurons())
                {
                    n.DeleteAllSynapes();
                }
            }

            //since we are inserting at 0, these are in reverse order
            UKS.Insert(0, new Thing {
                Label = "Sleep"
            });
            UKS.Insert(0, new Thing {
                Label = "Max"
            });
            UKS.Insert(0, new Thing {
                Label = "Ref"
            });
            UKS.Insert(0, new Thing {
                Label = "Parent"
            });
            firstThing  = 4;
            EventCount  = 0;
            phraseCount = 0;

            //add connections from speakPhonemes to this module

            ModuleView naPhonemes = theNeuronArray.FindAreaByLabel("ModuleSpeakPhonemes");

            if (naPhonemes != null)
            {
                Neuron n2 = GetNeuron(Labeled("SayRnd"));
                Neuron n3 = naPhonemes.GetNeuronAt("BabyTalk");
                if (n2 != null && n3 != null)
                {
                    n3.AddSynapse(n2.Id, 1);
                }
                Thing parent = Labeled("Vowel");
                foreach (Neuron n in naPhonemes.Neurons())
                {
                    if (n.Label == "Conson.")
                    {
                        parent = Labeled("Consonant");
                    }
                    if (n.Label.Length == 1)
                    {
                        string label = "spk" + n.Label;
                        Thing  pn    = AddThing(label, new Thing[] { parent });
                        Neuron n1    = GetNeuron(pn, false);
                        if (n1 != null)
                        {
                            n1.AddSynapse(n.Id, 1);
                        }
                    }
                }
            }

            UpdateNeuronLabels();
        }