Exemplo n.º 1
0
 def testFitness2Correlation(self):
     """Correlation should make a difference"""
     G = ArrayWrapper.array(CorelatedGame)
     for k in range(20):
         p = Dynamics.RandomDistribution(8)
         compare = Dynamics._QuickFitness2(p, G)
         fitness = Dynamics._Fitness2(p, G, 0.2)
         self.failIf(AlmostEqual(fitness, compare))
Exemplo n.º 2
0
 def testNumericFitness2Players(self):
     """Fitness2 and numeric_Fitness2 should yield the same values"""
     for i in range(20):
         G = array(GenRandomGame(2, 8))
         for k in range(5):
             p = Dynamics.RandomDistribution(8)
             compare = Dynamics._Fitness2(p, G, 0.2)
             fitness = Dynamics._numeric_Fitness2(p, G, 0.2)
             self.failUnless(AlmostEqual(fitness, compare))
Exemplo n.º 3
0
 def testFitness2Players(self):
     """Fitness should be the same as Fitness2 in the 2 player case"""
     for i in range(20):
         G = array(GenRandomGame(2, 8))
         for k in range(5):
             p = Dynamics.RandomDistribution(8)
             compare = Dynamics._Fitness2(p, G, 0.2)
             fitness = Dynamics._Fitness(p, G, 0.2, 2)
             self.failUnless(AlmostEqual(fitness, compare))    
Exemplo n.º 4
0
 def testFitness2ZeroCorrelation(self):
     """Fitness2 should return the same results QuickFitness2 if e=0.0."""
     for i in range(20):
         G = array(GenRandomGame(2, 8))
         for k in range(5):
             p = Dynamics.RandomDistribution(8)
             compare = Dynamics._QuickFitness2(p, G)
             fitness = Dynamics._Fitness2(p, G, 0.0)
             self.failUnless(AlmostEqual(fitness, compare))
Exemplo n.º 5
0
 def testSampledFitness2(self):
     """SampledFitness2 should yield roughly the same results as Fitness2"""
     for i in range(5):
         G = array(GenRandomGame(2, 8))
         p = Dynamics.RandomDistribution(8)
         fitness = Dynamics._Fitness2(p, G, 0.2)
         failures = 0
         for k in range(5):
             sampled = Dynamics._SampledFitness2(p, G, 0.2, 1000)
             if not AlmostEqual(fitness, sampled, 0.1): failures += 1
             self.failIf(failures > 1)