Beispiel #1
0
        //public Type FilterType { get; set; }

        #endregion

        #region Public Methods

        public override ShipPartDNA GetDNA()
        {
            SensorVisionDNA retVal = new SensorVisionDNA();

            base.FillDNA(retVal);
            retVal.SearchRadius = SearchRadius;
            //retVal.FilterType = FilterType;

            return(retVal);
        }
Beispiel #2
0
        private static NeuronLayer[] CreateNeurons_Layers(SensorVisionDNA dna, ItemOptionsArco itemOptions)
        {
            if (dna.Filters == null || dna.Filters.Length == 0)
            {
                throw new ApplicationException("This method requires filters to be populated");
            }

            var count = GetNeuronCount(dna.Scale, itemOptions.Sensor_NeuronGrowthExponent, itemOptions.VisionSensor_NeuronDensity);

            //TODO: SensorVisionFilterType.Bot will need two layers
            var neuronZs = GetNeuron_Zs(dna.Filters.Length, count.radius);

            Point3D[] staticPositions = new Point3D[] { new Point3D(0, 0, 0) };

            Point3D[] singlePlate = null;
            if (dna.Neurons != null && dna.Neurons.Length > 0)
            {
                var byLayer = NeuralUtility.DivideNeuronLayersIntoSheets(dna.Neurons, neuronZs.z, count.neuronCount);

                // Just use one of the layer's positions to re evenly distribute (first layer with the correct number of neurons - or closest number).
                // Could try to find the nearest between each layer and use the average of each set, but that's a lot of expense with very little payoff
                singlePlate = GetBestNeuronSheet(byLayer, count.neuronCount);
            }

            // Make sure there is a correct number of neurons and apply an even distribution
            singlePlate = NeuralUtility.GetNeuronPositions_Circular_Even(singlePlate, staticPositions, 1d, count.neuronCount, count.radius).
                          Select(o => o.ToPoint()).
                          ToArray();

            // Use the location of neurons in this single layer for all layers.  By making sure that each neuron represents the same point in each
            // layer (and the index of that neuron is the same in each layer), position logic in each tick can be optimized
            return(Enumerable.Range(0, dna.Filters.Length).
                   Select(o => new NeuronLayer()
            {
                FilterType = dna.Filters[o],
                Z = neuronZs.z[o],
                Neurons = singlePlate.
                          Select(p => new Neuron_SensorPosition(new Point3D(p.X, p.Y, neuronZs.z[o]), true, true)).
                          ToArray(),
            }).
                   ToArray());
        }
Beispiel #3
0
        public SensorVision(EditorOptions options, ItemOptionsArco itemOptions, SensorVisionDNA dna, Map map)
            : base(options, dna, itemOptions.VisionSensor_Damage.HitpointMin, itemOptions.VisionSensor_Damage.HitpointSlope, itemOptions.VisionSensor_Damage.Damage)
        {
            _itemOptions = itemOptions;
            _map         = map;

            Design = new SensorVisionDesign(options, true);
            Design.SetDNA(dna);

            double radius, volume;

            SensorGravity.GetMass(out _mass, out volume, out radius, out _scaleActual, dna, itemOptions);

            Radius = radius;

            if (dna.Filters == null || dna.Filters.Length == 0)
            {
                _neurons      = CreateNeurons(dna, itemOptions, itemOptions.VisionSensor_NeuronDensity, true, true);
                _neuronLayers = null;
                _allNeurons   = _neurons;

                var distances = GetNeuronAvgDistance(_neurons.Select(o => o.Position.ToPoint2D()).ToArray());
                _neuronDistBetween = distances.distBetween;
                _neuronMaxRadius   = distances.maxRadius;
            }
            else
            {
                _neuronLayers = CreateNeurons_Layers(dna, itemOptions);
                _neurons      = null;
                _allNeurons   = _neuronLayers.
                                SelectMany(o => o.Neurons).
                                ToArray();

                var distances = GetNeuronAvgDistance(_neuronLayers[0].Neurons.Select(o => o.Position.ToPoint2D()).ToArray());     // all the layers have neurons in the same place
                _neuronDistBetween = distances.distBetween;
                _neuronMaxRadius   = distances.maxRadius;
            }

            SearchRadius = dna.SearchRadius;       // need to set this last, because it populates _distProps
        }