Ejemplo n.º 1
0
        public override void Fire()
        {
            Init();  //be sure to leave this here to enable use of the na variable

            double[] rotation = { -Math.PI / 2, -Math.PI / 24, 0, Math.PI / 24, Math.PI / 2 };

            float direction = 0;

            for (int i = 0; i < na.Width; i++)
            {
                if (na.GetNeuronAt(i, 0).LastCharge > 0.9 || na.GetNeuronAt(i, 0).LastCharge > 0.9 && i < rotation.Length)
                {
                    direction = (float)rotation[i];
                }
            }
            if (na.GetNeuronAt(2, 0).CurrentCharge != 0)
            {
                direction = na.GetNeuronAt(2, 0).CurrentCharge;
                na.GetNeuronAt(2, 0).SetValue(0);
            }

            ModuleRealityModel mrm = (ModuleRealityModel)FindModuleByType(typeof(ModuleRealityModel));

            if (mrm != null && direction != 0)
            {
                mrm.Rotate(20);
            }

            Module2DSim m2D = (Module2DSim)FindModuleByType(typeof(Module2DSim));

            if (m2D != null && direction != 0)
            {
                m2D.Rotate(direction);
            }

            Module3DSim m3D = (Module3DSim)FindModuleByType(typeof(Module3DSim));

            if (m3D != null && direction != 0)
            {
                m3D.Rotate(direction);
            }

            Module2DModel m2DModel = (Module2DModel)FindModuleByType(typeof(Module2DModel));

            if (m2DModel != null && direction != 0)
            {
                m2DModel.Rotate(direction);
            }

            Module2DVision m2DVision = (Module2DVision)FindModuleByType(typeof(Module2DVision));

            if (m2DVision != null && direction != 0)
            {
                m2DVision.ViewChanged();
            }
        }
Ejemplo n.º 2
0
        public override void Fire()
        {
            Init();  //be sure to leave this here to enable use of the na variable
            float[] dist    = { .5f, .1f, 0, -.025f, -.1f };
            float   motionX = 0;
            float   motionY = 0;

            if (na.Width < 3)
            {
                Initialize();
            }

            for (int i = 0; i < na.Height; i++)
            {
                if (na.GetNeuronAt(1, i).LastCharge > 0.9)
                {
                    motionX = dist[i];
                }
            }

            if (na.GetNeuronAt(1, 2).CurrentCharge != 0)
            {
                motionX = na.GetNeuronAt(1, 2).CurrentCharge;
                na.GetNeuronAt(1, 2).SetValue(0);
            }

            if (na.GetNeuronAt(0, 2).LastCharge > 0.9)
            {
                motionY = 0.5f;
            }
            if (na.GetNeuronAt(2, 2).LastCharge > 0.9)
            {
                motionY = -0.5f;
            }


            //obsolete
            ModuleRealityModel mrm = (ModuleRealityModel)FindModuleByType(typeof(ModuleRealityModel));

            if (mrm != null)
            {
                mrm.Move(motionX);
            }

            Module3DSim m3D = (Module3DSim)FindModuleByType(typeof(Module3DSim));

            if (m3D != null && motionX != 0)
            {
                m3D.Move(motionX);
            }

            bool        moved = false;
            Module2DSim m2D   = (Module2DSim)FindModuleByType(typeof(Module2DSim));

            if (m2D != null && motionX != 0 || motionY != 0)
            {
                moved = m2D.Move(motionX, motionY);
            }

            Module2DModel m2DModel = (Module2DModel)FindModuleByType(typeof(Module2DModel));

            if (m2DModel != null && moved && motionX != 0 || motionY != 0)
            {
                m2DModel.Move(motionX, motionY);
            }

            Module2DVision m2DVision = (Module2DVision)FindModuleByType(typeof(Module2DVision));

            if (m2DVision != null && motionX != 0)
            {
                m2DVision.ViewChanged();
            }
        }