Ejemplo n.º 1
0
 private void GenerateParts(BugStructur bugStructur)
 {
     foreach (BugPartData part in mBugStructur)
     {
         CreateBugPart(part.Fuction, part.ParentConnection, part.Connections[part.ParentConnection]);
     }
 }
Ejemplo n.º 2
0
        protected void GenerateBug(BugStructur bugStructur)
        {
            mBugStructur = bugStructur;

            SetDefault(mBugStructur.AmountOf(typeof(Eye)), mBugStructur.AmountOf(typeof(Body)));

            GenerateParts(mBugStructur);
        }
Ejemplo n.º 3
0
        public BugDNA(BugStructur stucture, float[][][] weights, float[][] bases)
        {
            mBugValues = new Dictionary <BugValue, float>();

            foreach (BugValue item in Enum.GetValues(typeof(BugValue)))
            {
                mBugValues[item] = 0.0f;
            }

            Stucture = stucture;
            Weights  = weights;
            Bases    = bases;
        }
Ejemplo n.º 4
0
        private BugStructur Crossover(BugStructur other, BugStructur that)
        {
            BugStructur buffer = new BugStructur();

            other.CalculatePoses();
            that.CalculatePoses();

            int MaxX = (int)Mathn.GetBigger(other.MaxX(), that.MaxX());
            int MaxY = (int)Mathn.GetBigger(other.MaxY(), that.MaxY());
            int MinX = (int)Mathn.GetBigger(other.MinX(), that.MinX());
            int MinY = (int)Mathn.GetBigger(other.MinY(), that.MinY());

            for (int x = MinX; x <= MaxX; x++)
            {
                for (int y = MinY; y <= MaxY; y++)
                {
                    BugPartData th = that.GetPartData(new Vector2(x, y));
                    BugPartData ot = that.GetPartData(new Vector2(x, y));

                    if (th == null && ot == null)
                    {
                        continue;
                    }

                    if (ot == th)
                    {
                        buffer.AddVecPart(new Vector2(x, y), th.Fuction);
                        continue;
                    }

                    if (th != null && ot != null)
                    {
                        buffer.AddVecPart(new Vector2(x, y), mRandom.NextBool() ? th.Fuction : ot.Fuction);
                        continue;
                    }

                    if (th == null)
                    {
                        th = ot;
                    }

                    if (mRandom.NextBool())
                    {
                        buffer.AddVecPart(new Vector2(x, y), th.Fuction);
                    }
                }
            }

            buffer.WriteVecParts();
            return(buffer);
        }
Ejemplo n.º 5
0
        public virtual BugStructur GetBugStructur()
        {
            if (mBugStructur != null)
            {
                return(mBugStructur);
            }

            BugStructur d = new BugStructur();

            foreach (BugPart item in mBugParts)
            {
                d.AddBugPart(item);
            }

            return(d);
        }
Ejemplo n.º 6
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            if (EditorGUILayout.DropdownButton(new GUIContent("Load"), FocusType.Passive))
            {
                Bug b = ((BugTester)target).MakeBug();
                b.Load();
                mBS = b.GetBugStructur();
            }

            if (EditorGUILayout.DropdownButton(new GUIContent("Make Copy of Last"), FocusType.Passive))
            {
                Bug b = ((BugTester)target).MakeBug();
                //b.Load(mBS);
            }
        }