lundi 2 mars 2020

Difficulty generating unique arrays for each parent object

I'm making a genetic simulator for a game and when I call my function to populate the array that determines the parents gene's it gives the same output for each parent.

Outputs would generally look like this. ruby = [G, U, B, N, N, G] jaune = [G, U, B, N, N, G]

The output I want would be something like this. ruby = [R, A, N, R, N, B] jaune = [W, N, W, N, N A]

import random
import time

class Parent():
    magic = [None, None, None, None, None, None]


    types = ['B', 'U', 'W', 'R', 'G', 'N', 'A']
    def gen(self):
        for i in range(0, 6):
            self.magic[i] = self.types[random.randint(0, 6)]


    def traits(self):
        print (self.magic)



jaune = Parent()
ruby = Parent()

jaune.gen()
ruby.gen()

jaune.traits()
ruby.traits()




Aucun commentaire:

Enregistrer un commentaire