Exemplo n.º 1
0
        void SetCenterColor()
        {
            int        c1    = GetNeuronValueInt(null, na.Width / 2, 0);
            int        c2    = GetNeuronValueInt(null, na.Width / 2, 1);
            ModuleUKSN nmUKS = (ModuleUKSN)FindModuleByType(typeof(ModuleUKSN));

            if (nmUKS != null && nmUKS.Labeled("Color") != null)
            {
                List <Thing> colors = nmUKS.Labeled("Color").Children;
                //if (c1 != 0)
                {
                    nmUKS.Fire(nmUKS.Valued(c1, colors));
                }
                //if (c2 != 0)
                {
                    nmUKS.Fire(nmUKS.Valued(c2, colors));
                }
            }
        }
Exemplo n.º 2
0
        public override void Fire()
        {
            Init();  //be sure to leave this here
            if (words.Count > 0)
            {
                string word = words[0];
                na.BeginEnum();
                for (Neuron n = na.GetNextNeuron(); n != null; n = na.GetNextNeuron())
                {
                    if (n.Label == word)
                    {
                        n.SetValue(1);
//                        n.CurrentCharge = 1;
                        break;
                    }
                    else if (n.Label == "")
                    {
                        //the word has not been heard before, add it
                        n.Label         = word;
                        n.CurrentCharge = 1;
                        //connection to UKS
                        ModuleUKSN nmUKS = (ModuleUKSN)FindModuleByType(typeof(ModuleUKSN));
                        if (nmUKS != null)
                        {
                            List <Thing> words = nmUKS.Labeled("Word").Children;
                            Thing        w     = nmUKS.Valued(word, words);
                            if (w == null)
                            {
                                string label = "w" + char.ToUpper(word[0]) + word.Substring(1);
                                w = nmUKS.AddThing(label, new Thing[] { nmUKS.Labeled("Word") }, word);
                            }
                            Neuron n1 = nmUKS.GetNeuron(w);
                            if (n1 != null)
                            {
                                n.AddSynapse(n1.Id, 1);
                            }
                            //TODO: add a synapse to the speakwords module as well
                        }
                        break;
                    }
                }
                words.RemoveAt(0);
            }
        }