Beispiel #1
0
        public override List <PrimitiveTriple <float, float, float> > Generate(GridMath gridMath, Random rand)
        {
            // Call base function to generate 2D positions
            List <PrimitiveTriple <float, float, float> > posList = base.Generate(gridMath, rand);

            // Set altitudes randomly
            foreach (PrimitiveTriple <float, float, float> tempPos in posList)
            {
                tempPos.second = RandN(altitudeMean_km, altitudeStdDev_km, altitudeMin_km, altitudeMax_km, rand);
            }

            return(posList);
        }
Beispiel #2
0
        virtual public List <PrimitiveTriple <float, float, float> > Generate(GridMath gridMath, Random rand)
        {
            // List to return
            List <PrimitiveTriple <float, float, float> > posList = new List <PrimitiveTriple <float, float, float> >();

            // First determine the # of units
            int numUnits = (int)Math.Ceiling(numMean);

            if (numStdDev > 0)
            {
                numUnits = (int)Math.Round(RandN(numMean, numStdDev, (float)numMin, (float)numMax, rand));
            }
            // For each unit
            PrimitivePair <float, float> tempPos = new PrimitivePair <float, float>(0, 0);
            PrimitivePair <float, float> anchor;
            PrimitivePair <int, int>     tempGrid;
            bool laydownFound;

            for (int i = 0; i < numUnits; i++)
            {
                // Laydown not valid by default
                laydownFound = false;

                // Randomly pick an anchor (all anchors already in world coordinates)
                anchor = anchors[rand.Next(0, anchors.Count)]; // Note: rand.Next max value is exclusive

                // Keep trying points until we find one that satisfies grid constraints
                while (!laydownFound)
                {
                    // Now independently pick X and Z deviations from that point
                    tempPos.first  = anchor.first + RandN(0.0f, fromAnchorStdDev_km, 0.0f, fromAnchorMax_km, rand);
                    tempPos.second = anchor.second + RandN(0.0f, fromAnchorStdDev_km, 0.0f, fromAnchorMax_km, rand);

                    // Convert that temp position to grid
                    tempGrid = gridMath.WorldToGrid(tempPos);

                    // Check to see if the grid is within allowed
                    if (allowedCells.Contains(tempGrid))
                    {
                        laydownFound = true;
                    }
                }

                // Save the 3D point
                posList.Add(new PrimitiveTriple <float, float, float>(tempPos.first, 0, tempPos.second));
            }

            // Return list of randomized positions
            return(posList);
        }
        public MCTrialGenerator()
        {
            // Read in envConfig
            envConfig = EnvConfigXMLReader.Parse(envConfigFile);
            if (envConfig == null)
            {
                Log.debug("MCTrialGenerator::Main(): Parsed envConfig is null, exiting");
                return;
            }

            // Initialize GridMath object
            gridMath = new GridMath(envConfig.gridOrigin_x, envConfig.gridOrigin_z, envConfig.gridToWorldScale);

            // Populate hashsets of cells for easy lookup
            landCells         = new HashSet <PrimitivePair <int, int> >(envConfig.landCells);
            landAndWaterCells = new HashSet <PrimitivePair <int, int> >(envConfig.landCells);
            landAndWaterCells.UnionWith(envConfig.waterCells);

            // Random generator for determining whether a unit has weapons or jammers etc.
            rand = new Random(generatorRandomSeed);
        }
Beispiel #4
0
        public MCTrialGenerator()
        {
            // Read in envConfig
            envConfig = EnvConfigXMLReader.Parse(envConfigFile);
            if (envConfig == null)
            {
                Log.debug("MCTrialGenerator::Main(): Parsed envConfig is null, exiting");
                return;
            }

            // Initialize GridMath object
            gridMath = new GridMath(envConfig.gridOrigin_x, envConfig.gridOrigin_z, envConfig.gridToWorldScale);

            // Populate hashsets of cells for easy lookup
            landCells         = new HashSet <PrimitivePair <int, int> >(envConfig.landCells);
            landAndWaterCells = new HashSet <PrimitivePair <int, int> >(envConfig.landCells);
            landAndWaterCells.UnionWith(envConfig.waterCells);

            // Random generator for determining whether a unit has weapons or jammers etc.
            rand = new Random(generatorRandomSeed);

            // Type of experiment that will be run
            switch (experimentType)
            {
            case ExperimentType.COMMS_RANGE:
                experiment = new CommsRangeExperiment(this);
                break;

            case ExperimentType.BLUE_NUM:
                experiment = new SmallUAVNumberExperiment(this);
                break;

            case ExperimentType.RED_NUM:
                experiment = new RedAgentNumberExperiment(this);
                break;

            case ExperimentType.RED_PRED:
                experiment = new RedMovePredExperiment(this);
                break;

            case ExperimentType.FACTORIAL:
                experiment = new FactorialExperiment(this);
                break;
            }

            // Blue Base
            blueBases = new List <SiteConfig>();
            blueBases.Add(new BlueBaseConfig(-3.02830208f, -9.7492255f, "Blue Base", new Optional <float>()));

            // Red Base
            redBases = new List <SiteConfig>();
            redBases.Add(new RedBaseConfig(-17.7515077f, 13.7463599f, "Red Base 0"));
            redBases.Add(new RedBaseConfig(-0.439941213f, 12.7518844f, "Red Base 1"));
            redBases.Add(new RedBaseConfig(22.0787984f, 10.7493104f, "Red Base 2"));

            // NGO Site
            ngoSites = new List <SiteConfig>();
            ngoSites.Add(new NGOSiteConfig(-21.2181483f, -1.25010618f, "NGO Site 0"));
            ngoSites.Add(new NGOSiteConfig(-4.76803318f, -5.74888572f, "NGO Site 1"));
            ngoSites.Add(new NGOSiteConfig(11.6916982f, 4.76402643f, "NGO Site 2"));
            ngoSites.Add(new NGOSiteConfig(24.6807822f, -6.75057337f, "NGO Site 3"));

            // Village
            villages = new List <SiteConfig>();
            villages.Add(new VillageConfig(-16.0197901f, 5.74808437f, "Village 0"));
            villages.Add(new VillageConfig(-14.296086f, -3.22944096f, "Village 1"));
            villages.Add(new VillageConfig(-5.63349131f, 4.74559538f, "Village 2"));
            villages.Add(new VillageConfig(7.34998325f, -0.743652906f, "Village 3"));
            villages.Add(new VillageConfig(-13.4306279f, -11.7638197f, "Village 4"));
        }