Exemplo n.º 1
0
    private int MUTATION_CYCLES = 12; // maximum mutations per evolution

    public RoomConfiguration(RoomConfiguration parentRoom, int returnPortalID, int championPortalID, Artwork[] artworksPassed, Sculpture[] sculptures)
    {
        ArtGallery ag       = ArtGallery.GetArtGallery();
        Artwork    champion = artworksPassed[championPortalID];

        if (ArtGallery.DEBUG_LEVEL < ArtGallery.DEBUG.NONE)
        {
            Debug.Log("Creating a new room with " + artworksPassed.Length + " artworks");
        }
        this.parentRoom = parentRoom;

        rooms = new RoomConfiguration[artworksPassed.Length];
        if (ArtGallery.DEBUG_LEVEL < ArtGallery.DEBUG.NONE)
        {
            Debug.Log("Clearing artworks and sculptures...");
        }
        artworks        = new Artwork[artworksPassed.Length];
        this.sculptures = sculptures;
        if (ArtGallery.DEBUG_LEVEL < ArtGallery.DEBUG.NONE)
        {
            Debug.Log("Created new artworks: " + artworksPassed.Length);
        }
        rooms[returnPortalID] = parentRoom;

        // clone champion to each artwork and mutate
        for (int i = 0; i < artworksPassed.Length; i++)
        {
            TWEANNGenotype geno = new TWEANNGenotype(champion.GetGenotype().Copy());
            // champion art
            if (i == championPortalID)
            {
                //do little
                geno.Mutate();
            }
            // return art
            else if (i == returnPortalID)
            {
                // do nothing - save some cpu
            }
            else
            {
                // all other art
                TWEANNCrossover cross = new TWEANNCrossover(false)
                {
                    Sucessful = false
                }; //HACK PROTOTYPE hardcoded value
                   //TWEANNGenotype crossedGeno = cross.Crossover(new TWEANNGenotype(geno.Copy()), new TWEANNGenotype(champion.GetGenotype().Copy()));
                   //geno = crossedGeno;

                for (int m = 0; m < Random.Range(2, ag.artworkMutationChances); m++)
                {
                    geno.Mutate();
                }
            }
            artworks[i] = new Artwork(geno);
        }

        MutateSculptures();
    }
Exemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        if (art != null && art.NeedsRedraw())
        {
            art.ApplyImageProcess();
            img = art.GetArtwork();
            renderer.material.mainTexture = img;
            Debug.Log("Image applied");
        }

        if (!PauseMenu.isPaused && Input.GetButtonDown("Fire2"))
        {
            img = new Texture2D(width, height, TextureFormat.ARGB32, true);
            art = new Artwork();
            textbox.Text("New image and genome");
        }

        if (!PauseMenu.isPaused && Input.GetButtonDown("Fire1"))
        {
            TWEANNGenotype geno = art.GetGenotype();
            geno.Mutate();
            textbox.Text("Mutating...");
            art = new Artwork(geno);
        }
    }
Exemplo n.º 3
0
    private void MutateArtworks()
    {
        leftGeno  = new TWEANNGenotype(NUM_INPUTS, NUM_OUTPUTS, 0);
        rightGeno = new TWEANNGenotype(NUM_INPUTS, NUM_OUTPUTS, 0);

        for (int i = 0; i < 10; i++)
        {
            leftGeno.Mutate();
            rightGeno.Mutate();
        }
    }
Exemplo n.º 4
0
    public void MutateSculptures()
    {
        ArtGallery ag = ArtGallery.GetArtGallery();

        //Sort Sculptures
        Sculpture[]    toMutate          = new Sculpture[sculptures.Length];
        TWEANNGenotype sculptureChampion = null;

        for (int s = 0; s < sculptures.Length; s++)
        {
            if (sculptures[s].GetSelected())
            {
                sculptureChampion = new TWEANNGenotype(sculptures[s].GetGenotype().Copy());
                sculptures[s].SetSelected(false);
                toMutate[s] = sculptures[s];
            }
            else
            {
                toMutate[s] = sculptures[s];
            }
        }

        //Select sculpture champion and crossover / mutate
        if (sculptureChampion != null)
        {
            for (int m = 0; m < sculptures.Length; m++)
            {
                Sculpture ms = toMutate[m];
                if (ms != null)
                {
                    TWEANNGenotype  crossedGeno = new TWEANNGenotype(sculptureChampion.Copy());
                    TWEANNCrossover cross       = new TWEANNCrossover(false)
                    {
                        Sucessful = false
                    }; // HACK PROTOTYPE hardcoded value
                       //TWEANNGenotype crossedmgeno = cross.Crossover(new TWEANNGenotype(sculptureChampion.Copy()), new TWEANNGenotype(ms.GetGenotype().Copy()));
                       //crossedGeno = crossedmgeno;

                    for (int mr = 0; mr < Random.Range(2, ag.sculptureMutationChances); mr++) //HACK PROTOTYPE hardcoded value for mutation rate
                    {
                        crossedGeno.Mutate();
                    }

                    ms.NewSculpture(new TWEANNGenotype(crossedGeno));
                }
            }
        }
    }
Exemplo n.º 5
0
 /// <summary>
 /// Mutate genome
 /// </summary>
 public void Mutate()
 {
     geno.Mutate();
 }