예제 #1
0
        public override void mutate(int mutationflags, float mutationstrength)
        {
            base.mutate(mutationflags, mutationstrength);
            //Also mutates pcolorstyle fields.

            /* Mutates _radius
             *  and calls setRadius, which does a scaling operation. */
            _pdotcolorstyle.mutate(mutationflags, mutationstrength);
            //The dots
            if ((mutationflags & MF_DOTS) != 0)
            {
                Dotted = _dotted ^ Framework.randomOb.randomBOOL(mutationstrength / 2.0f);
                _realdotradiusweight =
                    Framework.randomOb.mutate(_realdotradiusweight, 0.2f, 0.4f, mutationstrength);
            }
            //Number of vertices
            if ((mutationflags & MF_VERTCOUNT) != 0)
            {
                int newcount;
                if (vertCount() == 0)
                { //Creating a new Shape
                    if (Framework.randomOb.randomBOOL(0.5f))
                    {
                        setRegularShape(Framework.randomOb.random(2, 9), Center, _radius, Angle);
                    }
                    else
                    {
                        newcount = Framework.randomOb.random(5, 14);
                        setRandomStarShape(newcount, newcount);
                    }
                }
                else if (Framework.randomOb.randomBOOL(mutationstrength)) //Mutate an existing one
                {
                    int minsides = max(2, vertCount() - 2);
                    int maxsides = min(9, vertCount() + 2);
                    if (Framework.randomOb.randomBOOL(0.5f))
                    {
                        newcount = Framework.randomOb.random(minsides, maxsides);
                        setRegularShape(newcount, Center, _radius, Angle);
                    }
                    else
                    {
                        minsides = max(5, vertCount() - 2);
                        maxsides = min(14, vertCount() + 2);
                        newcount = Framework.randomOb.random(minsides, maxsides);
                        setRandomStarShape(newcount, newcount);
                    }
                }
            }
            //Fixups
            if (vertCount() == 2)       //Don't want any plain old line segments.
            {
                Dotted = true;
            }
            Radius           = _radius; /* Set the radius last, as it depends on the line width,
                                         * dots, etc. */
            _newgeometryflag = true;
        }
예제 #2
0
        //3D Mutators 

        //Randomizing mutators 

        public virtual void mutate(int mutationflags, float mutationstrength)
        {
            if ((mutationflags & MF_RADIUS) != 0)
                Radius = Framework.randomOb.mutate(
                    _radius, cCritter.MinRadius, cCritter.MaxRadius,
                    mutationstrength);
            if ((mutationflags & MF_ROTATION) != 0)
                rotate(Framework.randomOb.mutate(Angle, 0.0f, (float)Math.PI, mutationstrength));
            _pcolorstyle.mutate(mutationflags, mutationstrength);
            _newgeometryflag = true;
        }