SwapShapes() 공개 메소드

public SwapShapes ( Random rand ) : void
rand Random
리턴 void
예제 #1
0
        DNA IMutator.Mutate( Random rand, DNA oldDNA, TaskState task )
        {
            DNA newDNA = new DNA( oldDNA );
            if( rand.Next( 20 ) == 0 ) {
                newDNA.SwapShapes( rand );
            } else {
                MutateShape( rand, newDNA, newDNA.Shapes[rand.Next( newDNA.Shapes.Length )], task );
            }

            return newDNA;
        }
예제 #2
0
        DNA IMutator.Mutate(Random rand, DNA oldDNA, TaskState task)
        {
            DNA newDNA = new DNA(oldDNA);

            if (rand.Next(20) == 0)
            {
                newDNA.SwapShapes(rand);
            }
            else
            {
                MutateShape(rand, newDNA, newDNA.Shapes[rand.Next(newDNA.Shapes.Length)], task);
            }

            return(newDNA);
        }
예제 #3
0
        public DNA Mutate(Random rand, DNA oldDNA, TaskState task)
        {
            DNA   newDNA = new DNA(oldDNA);
            int   s1     = rand.Next(newDNA.Shapes.Length);
            Shape shape  = newDNA.Shapes[s1];

            if (rand.Next(20) == 0)
            {
                newDNA.SwapShapes(rand);
            }
            else
            {
                MutateShape(rand, newDNA, shape, task);
            }
            return(newDNA);
        }
예제 #4
0
 public DNA Mutate( Random rand, DNA oldDNA, TaskState task )
 {
     DNA newDNA = new DNA( oldDNA );
     int s1 = rand.Next( newDNA.Shapes.Length );
     Shape shape = newDNA.Shapes[s1];
     switch( rand.Next( 20 ) ) {
         case 0:
             newDNA.SwapShapes( rand );
             break;
         case 1:
             RandomizeShape( rand, shape, task );
             newDNA.LastMutation = MutationType.ReplaceShape;
             break;
         default:
             MutateShape( rand, newDNA, shape, task );
             break;
     }
     return newDNA;
 }
예제 #5
0
        public DNA Mutate(Random rand, DNA oldDNA, TaskState task)
        {
            DNA   newDNA = new DNA(oldDNA);
            int   s1     = rand.Next(newDNA.Shapes.Length);
            Shape shape  = newDNA.Shapes[s1];

            switch (rand.Next(20))
            {
            case 0:
                newDNA.SwapShapes(rand);
                break;

            case 1:
                RandomizeShape(rand, shape, task);
                newDNA.LastMutation = MutationType.ReplaceShape;
                break;

            default:
                MutateShape(rand, newDNA, shape, task);
                break;
            }
            return(newDNA);
        }
예제 #6
0
        public DNA Mutate(Random rand, DNA oldDNA, TaskState task)
        {
            DNA newDNA = new DNA(oldDNA);

            Shape shape  = newDNA.Shapes[rand.Next(newDNA.Shapes.Length)];
            int   choice = rand.Next((EnableRotation ? 16 : 12));

            switch (choice)
            {
            case 0:
            case 1:
                shape.PreviousState = shape.Clone() as Shape;
                MoveShape(rand, shape, task);
                newDNA.LastMutation = MutationType.Move;
                break;

            case 2:
            case 3:
                shape.PreviousState = shape.Clone() as Shape;
                ScaleShape(rand, shape, task);
                newDNA.LastMutation = MutationType.Scale;
                break;

            case 4:
                shape.PreviousState = shape.Clone() as Shape;
                ScaleShape(rand, shape, task);
                MoveShape(rand, shape, task);
                newDNA.LastMutation = MutationType.Transform;
                break;

            case 5:
                shape.PreviousState = shape.Clone() as Shape;
                MoveShape(rand, shape, task);
                ScaleShape(rand, shape, task);
                newDNA.LastMutation = MutationType.Transform;
                break;

            case 6:
            case 7:
            case 8:
            case 9:
                shape.PreviousState = shape.Clone() as Shape;
                ChangeColor(rand, shape, task);
                newDNA.LastMutation = MutationType.AdjustColor;
                break;

            case 10:
                newDNA.SwapShapes(rand);
                break;

            case 11:
                shape.PreviousState = shape.Clone() as Shape;
                MoveShape(rand, shape, task);
                ScaleShape(rand, shape, task);
                ChangeColor(rand, shape, task);
                newDNA.LastMutation = MutationType.Transform;
                break;

            case 12:
            case 13:
                shape.PreviousState = shape.Clone() as Shape;
                RotateShape(rand, shape);
                newDNA.LastMutation = MutationType.Rotate;
                break;

            case 14:
                shape.PreviousState = shape.Clone() as Shape;
                MoveShape(rand, shape, task);
                RotateShape(rand, shape);
                newDNA.LastMutation = MutationType.Transform;
                break;

            case 15:
                shape.PreviousState = shape.Clone() as Shape;
                ChangeColor(rand, shape, task);
                newDNA.LastMutation = MutationType.AdjustColor;
                break;
            }
            return(newDNA);
        }
예제 #7
0
 public DNA Mutate( Random rand, DNA oldDNA, TaskState task )
 {
     DNA newDNA = new DNA( oldDNA );
     int s1 = rand.Next( newDNA.Shapes.Length );
     Shape shape = newDNA.Shapes[s1];
     if( rand.Next( 20 ) == 0 ) {
         newDNA.SwapShapes( rand );
     } else {
         MutateShape( rand, newDNA, shape, task );
     }
     return newDNA;
 }
예제 #8
0
        public DNA Mutate( Random rand, DNA oldDNA, TaskState task )
        {
            DNA newDNA = new DNA( oldDNA );

            Shape shape = newDNA.Shapes[rand.Next( newDNA.Shapes.Length )];
            int choice = rand.Next( ( EnableRotation ? 16 : 12 ) );
            switch( choice ) {
                case 0:
                case 1:
                    shape.PreviousState = shape.Clone() as Shape;
                    MoveShape( rand, shape, task );
                    newDNA.LastMutation = MutationType.Move;
                    break;
                case 2:
                case 3:
                    shape.PreviousState = shape.Clone() as Shape;
                    ScaleShape( rand, shape, task );
                    newDNA.LastMutation = MutationType.Scale;
                    break;
                case 4:
                    shape.PreviousState = shape.Clone() as Shape;
                    ScaleShape( rand, shape, task );
                    MoveShape( rand, shape, task );
                    newDNA.LastMutation = MutationType.Transform;
                    break;
                case 5:
                    shape.PreviousState = shape.Clone() as Shape;
                    MoveShape( rand, shape, task );
                    ScaleShape( rand, shape, task );
                    newDNA.LastMutation = MutationType.Transform;
                    break;
                case 6:
                case 7:
                case 8:
                case 9:
                    shape.PreviousState = shape.Clone() as Shape;
                    ChangeColor( rand, shape, task );
                    newDNA.LastMutation = MutationType.ReplaceColor;
                    break;
                case 10:
                    newDNA.SwapShapes( rand );
                    break;
                case 11:
                    shape.PreviousState = shape.Clone() as Shape;
                    MoveShape( rand, shape, task );
                    ScaleShape( rand, shape, task );
                    ChangeColor( rand, shape, task );
                    newDNA.LastMutation = MutationType.Transform;
                    break;
                case 12:
                case 13:
                    shape.PreviousState = shape.Clone() as Shape;
                    RotateShape( rand, shape );
                    newDNA.LastMutation = MutationType.Rotate;
                    break;
                case 14:
                    shape.PreviousState = shape.Clone() as Shape;
                    MoveShape( rand, shape, task );
                    RotateShape( rand, shape );
                    newDNA.LastMutation = MutationType.Transform;
                    break;
                case 15:
                    shape.PreviousState = shape.Clone() as Shape;
                    ChangeColor( rand, shape, task );
                    newDNA.LastMutation = MutationType.ReplaceColor;
                    break;
            }
            return newDNA;
        }