def test_crew_adult(): gene00 = Gene() gene00.locus = 0 gene00.condition = "00" gene00.condition_prob = 1 gene00.congential = 1 # Congential = 0, Adult = 1 gene00.dominant = True # Genes are either recessive or dominant. We Mendel for now gene00.emp = 1 gene00.int = 1 gene00.cre = 1 gene01 = Gene() gene01.locus = 0 gene01.condition = "01" gene01.condition_prob = 1 gene01.congential = 1 #Congential = 0, Adult = 1 gene01.dominant = False #Genes are either recessive or dominant. We Mendel for now gene01.emp = -1 gene01.int = -1 gene01.cre = -1 crew1 = Crewmate() crew1.set_sex() crew1.set_name("01", "crew") crew1.genome.append([gene00, gene01]) crew2 = Crewmate() crew2.set_sex() crew2.set_name("02", "crew") crew2.genome.append([gene01, gene01]) crew1.mom = Crewmate() crew1.mom.name = "mom" crew1.dad = Crewmate() crew1.dad.name = "dad" crew2.mom = Crewmate() crew2.mom.name = "mom" crew2.dad = Crewmate() crew2.dad.name = "dad" return [crew1, crew2]
def import_crew(): temp = Ship() genetics = import_genetics() seed = [] for _ in range(100): mate = Crewmate() mate.set_sex() mate.set_name() mate.adult = True create_genome(mate, genetics) seed.append(mate) temp.crew = seed # while len(temp.crew) < 101: # temp.breed_all() # print "breeding" temp.breed_all() del temp.crew[0:100] for mate in temp.crew: mate.age = int(20 * random.random()) + 15 mate.become_adult() return temp.crew
def test_naming(): crew1 = Crewmate() crew2 = Crewmate() crew3 = Crewmate() crew1.set_name("foo", "bar") #remember, first name is last, last name is first if crew1.name != "bar foo": print "Error, name isn't being correctly set manually" print crew1.name + " should be bar foo" crew2.set_sex() crew2.set_name("bar") if "bar" not in crew2.name: print "Error, name isn't being set correctly when given just last name" print crew2.name + " should have last name bar" crew3.set_sex() crew3.set_name() if crew3.name == "Unnamed": print "Error, name isn't being set correctly when given no names" print crew3.name