def setUp(self): pd_org.MAX_BITS_OF_MEMORY = 4 pd_tournament.NUMBER_OF_ROUNDS = 2 self.organism_a = pd_org.PDOrg( pd_org.MemoryPDGenotype(1, [True, False], [False])) self.organism_b = pd_org.PDOrg( pd_org.MemoryPDGenotype(2, [True, False, False, True], [False, True]))
def setUp(self): pd_org.MAX_BITS_OF_MEMORY = 5 pd_selection.TOURNAMENT_SIZE = 2 self.organism_a = pd_org.PDOrg( pd_org.MemoryPDGenotype(1, [True, False], [False])) self.organism_b = pd_org.PDOrg( pd_org.MemoryPDGenotype(2, [True, False, False, True], [False, True])) self.organisms = [self.organism_a, self.organism_b] self.organism_a.average_payout = 0 self.organism_b.average_payout = 9.8
def test_get_tally_of_number_of_bits_of_memory(self): """ Returns a list of length MAX_BITS_OF_MEMORY + 1 where each position represents the number of organisms with that many number of bits of memory """ pd_org.MAX_BITS_OF_MEMORY = 4 organism_a = pd_org.PDOrg( pd_org.MemoryPDGenotype(1, [True, False], [False])) organism_b = pd_org.PDOrg( pd_org.MemoryPDGenotype(2, [True, False, False, True], [False, True])) organisms = [organism_a, organism_b, organism_a, organism_a] tally = pd_analysis.get_tally_of_number_of_bits_of_memory(organisms) expected = [0, 3, 1, 0, 0] self.assertEqual(tally, expected)