public static M.Random SafeRandom()
 {
     if (Random == null)
     {
         Random = new M.Random(DateTime.Now.Second);
     }
     return(Random);
 }
        public void Load(Func <Vector3> getRandomPos, M.Random random)
        {
            mGetRandomPos = getRandomPos;
            mRandom       = random;

            for (int i = 0; i < mStartGenSize; i++)
            {
                Vector3 p = mGetRandomPos();
                Bugs.Add(MakeBug(p.x, p.z));
            }
        }
Exemple #3
0
        public BugDNA Crossover(BugDNA other)
        {
            mRandom = GeneratorController.Random;

            BugDNA that = pGetBugDNA();
            BugDNA dna  = new BugDNA(Crossover(other.Stucture, that.Stucture), Crossover(other.Weights, that.Weights), Crossover(other.Bases, that.Bases));

            foreach (BugValue item in Enum.GetValues(typeof(BugValue)))
            {
                dna[item] = mRandom.NextBool() ? that[item] : other[item];
            }

            return(dna);
        }
        private void Start()
        {
            WallGenearator = mGenerators.WallGenearator;
            WallGenearator.Load();
            if (Random == null)
            {
                Random = new M.Random(DateTime.Now.Second);
            }

            FoodGenerator = mGenerators.FoodGenerator;
            FoodGenerator.Load(WallGenearator.CameraBounds);

            BugGenerator = mGenerators.BugGenerator;
            BugGenerator.Load(FoodGenerator.GetRandomPos, Random);

            NormalLayerMask    = LayerMask.GetMask(new string[] { "Food", "Wall" });
            HornyLayerMask     = LayerMask.GetMask(new string[] { "Food", "Wall", "Bug" });
            MeatLayerMask      = LayerMask.GetMask(new string[] { "Bug", "Wall" });
            BugLayerMask       = LayerMask.GetMask(new string[] { "Bug" });
            BugClickLayerMask  = LayerMask.GetMask(new string[] { "BugClick" });
            DisableTimeFuction = false;
        }