Exemple #1
0
 def testQuickFitnessFairGame(self):
     """Fitness should return equal fitnesses a 'totally fair' game"""
     G = ArrayWrapper.array(lambda a,b,c,d: 5.0)
     for i in range(10):
         r = Dynamics.RandomDistribution(7)
         f = Dynamics._QuickFitness(r, G, 4)
         for k in range(1,7):
             self.failIf(f[k] != f[0]) 
Exemple #2
0
 def testFitnessCorrelation(self):
     """Correlation should make a difference"""
     G = ArrayWrapper.array(CorelatedGame)
     for k in range(20):
         p = Dynamics.RandomDistribution(8)
         compare = Dynamics._QuickFitness(p, G, 3)
         fitness = Dynamics._Fitness(p, G, 0.2, 3)
         self.failIf(AlmostEqual(fitness, compare))                       
Exemple #3
0
 def testQuickFitness2FairGame(self):
     """QuickFitness2 should yield equal fitnesses in a totally fair game"""
     G = ArrayWrapper.array(lambda a,b: 0.3)
     for i in range(20):
         p = Dynamics.RandomDistribution(5)
         f = Dynamics._QuickFitness2(p, G)
         for k in range(1,5):
             self.failIf(f[k] != f[0])       
Exemple #4
0
def DynamicsTest():
    try:
        from Plot import awtGfx as GR
    except:
        from Plot import wxGfx as GR
    from Plot import Simplex
    import Dynamics
    import ArrayWrapper
        
    DemandGame = ArrayWrapper.array([[1/3., 1/3., 1/3.], 
                                     [2/3., 0., 0.],
                                     [1/2., 0., 1/2.]])
   
    gfx = GR.Window()
    tp = Simplex.Plotter(gfx, "Demand 1/3", "Demand 2/3", "Demand 1/2")
    diag = Simplex.Trajectory(tp,
               Dynamics.GenDynamicsFunction(DemandGame, e=0.06, noise=0.1),
               raster = Simplex.GenRaster(25))
    diag.step(8)
    gfx.waitUntilClosed()