コード例 #1
0
        private static Neuron_SensorPosition[] CreateNeurons(ShipPartDNA dna, ItemOptions itemOptions, double neuronDensity, bool ignoreSetValue)
        {
            #region Calculate Counts

            // Figure out how many to make
            //NOTE: This radius isn't taking SCALE into account.  The other neural parts do this as well, so the neural density properties can be more consistent
            double radius = (dna.Scale.X + dna.Scale.Y) / (2d * 2d);            // XY should always be the same anyway (not looking at Z for this.  Z is just to keep the sensors from getting too close to each other)
            double area   = Math.Pow(radius, itemOptions.Sensor_NeuronGrowthExponent);

            int neuronCount = Convert.ToInt32(Math.Ceiling(neuronDensity * area));
            if (neuronCount == 0)
            {
                neuronCount = 1;
            }

            #endregion

            // Place them evenly in a ring
            // I don't want a neuron in the center, so placing a static point there to force the neurons away from the center
            Vector3D[] positions = NeuralUtility.GetNeuronPositions_CircularShell_Even(dna.Neurons, neuronCount, radius);       //why 2D?

            // Exit Function
            return(positions.
                   Select(o => new Neuron_SensorPosition(o.ToPoint(), true, ignoreSetValue)).
                   ToArray());
        }
コード例 #2
0
        private static (Neuron_SensorPosition rot_dirspeed, Neuron_SensorPosition rot_radius, Neuron_SensorPosition[] linear) CreateNeurons(ShipPartDNA dna, ItemOptionsArco itemOptions)
        {
            #region ring - linear

            // Figure out how many to make
            //NOTE: This radius isn't taking SCALE into account.  The other neural parts do this as well, so the neural density properties can be more consistent
            double radius = (dna.Scale.X + dna.Scale.Y) / (2d * 2d);            // XY should always be the same anyway (not looking at Z for this.  Z is just to keep the sensors from getting too close to each other)
            double area   = Math.Pow(radius, itemOptions.MotionController2_NeuronGrowthExponent);

            int neuronCount = (area * itemOptions.MotionController2_NeuronDensity).ToInt_Ceiling();
            neuronCount += 2;       // manually add two for the rotation neruons

            if (neuronCount < 7)
            {
                neuronCount = 7;
            }

            var neuronPositions = SplitNeuronPositions(dna.Neurons);

            // Place them evenly around the perimiter of a circle.
            Vector3D[] linearPositions = NeuralUtility.GetNeuronPositions_CircularShell_Even(neuronPositions?.linear, neuronCount, radius);

            Neuron_SensorPosition[] linearNeurons = linearPositions.
                                                    Select(o => new Neuron_SensorPosition(o.ToPoint(), true, false)).
                                                    ToArray();

            #endregion

            #region interior - rotation

            Neuron_SensorPosition rotateDirSpeed = new Neuron_SensorPosition(new Point3D(-.25, 0, 0), false, false);
            Neuron_SensorPosition rotateRadius   = new Neuron_SensorPosition(new Point3D(.25, 0, 0), true, false);

            #endregion

            return
                (
                rotateDirSpeed,
                rotateRadius,
                linearNeurons
                );
        }