def OneGeneration(distribution, rounds): """Calculate one generation of the reiterated PD-simulation with exit option. 'distribution' is a 2-tuple that contains the population shares of CONO and ALL_D player's. 'rounds' is the number of rounds that are played until the strategy distribution is updated through replicator dynamics. The return value is a 2-tuple of the average score for each strategy. """ account = array([0.0, 0.0]) cc = distribution[0]**2 / 2 dd = distribution[1]**2 / 2 cd = distribution[0] * distribution[1] for i in xrange(rounds): account[0] += (2*cc*R + cd*S) / distribution[0] account[1] += (2*dd*P + cd*T) / distribution[1] poolC = cc * forced_exit * 2 + cd poolD = dd * 2 + cd pool = poolC + poolD cc += poolC**2 / (2 * pool) - cc*forced_exit dd = poolD**2 / (2 * pool) cd = poolC * poolD / pool account[0] /= rounds account[1] /= rounds return account
(See also: Brian Skyrms: Evolution of the Social Contract, Cambridge University Press, 1996, p.11-21.) """ try: from PyPlotter import awtGfx as GfxDriver except ImportError: from PyPlotter import wxGfx as GfxDriver from PyPlotter import Simplex import Dynamics from Compatibility import array payoff_table = array([[1./3, 1./3, 1./3], [2./3, 0., 0.], [1./2, 0., 1./2]]) def DemandGame(): """A population dynamical simulation of the demand game, demonstrating the use of simplex diagrams. """ # Open a window for graphics output. gfx = GfxDriver.Window(title="Demand Game") # Generate the appropriate dynamical function from the payoff table. dynamicsFunction = Dynamics.GenDynamicsFunction(payoff_table, e=0.0)
try: from PyPlotter import awtGfx as GfxDriver except ImportError: from PyPlotter import wxGfx as GfxDriver from PyPlotter import Graph, Gfx import Dynamics from Compatibility import array # Definition of the Game T, R, P, S = 6,4,2,1 # payoff parameter for the Prisoner's Dilemma forced_exit = 0.05 # Chance that cooperation is terminated by external factors initial_distribution = array([0.5, 0.5]) rounds = 200 generations = 50 def OneGeneration(distribution, rounds): """Calculate one generation of the reiterated PD-simulation with exit option. 'distribution' is a 2-tuple that contains the population shares of CONO and ALL_D player's. 'rounds' is the number of rounds that are played until the strategy distribution is updated through replicator dynamics. The return value is a 2-tuple of the average score for each strategy. """ account = array([0.0, 0.0]) cc = distribution[0]**2 / 2
if r1[s2[1]] == 1: payment += 0.25 return payment def GenPayoffTable(playerList): """Generates the payoff table for the players in 'playerList'. """ table = [] for player1 in playerList: line = [] for player2 in playerList: line.append(Payoff(player1, player2)) table.append(line) return table payoff_table = array(GenPayoffTable(PlayerNames)) def SignalingGame(): """Eine populationsdynamische Simulation des 'demand game'. """ # Open a window for graphics output. gfx = GfxDriver.Window(title = "Sender - Receiver Game") # Generate a dynamics function from the payoff table. dynFunc = Dynamics.GenDynamicsFunction(payoff_table, e=0.0,noise=0.0) # Set the graph for plotting the plotting dynamics.
takes the color of the patch that the population as drifted to. After a while all areas of attraction should have the colour of their respective attraction point. """ try: from PyPlotter import awtGfx as GfxDriver except ImportError: from PyPlotter import wxGfx as GfxDriver from PyPlotter import Simplex import Dynamics from Compatibility import array payoff_table = array([[1.0 / 3, 1.0 / 3, 1.0 / 3], [2.0 / 3, 0.0, 0.0], [1.0 / 2, 0.0, 1.0 / 2]]) def DemandGame(): """A population dynamical simulation of the demand game, demonstrating the use of simplex diagrams. """ # Open a window for graphics output. gfx = GfxDriver.Window(title="Demand Game") # Generate the appropriate dynamical function from the payoff table. dynamicsFunction = Dynamics.GenDynamicsFunction(payoff_table, e=0.0)
if r1[s2[1]] == 1: payment += 0.25 return payment def GenPayoffTable(playerList): """Generates the payoff table for the players in 'playerList'. """ table = [] for player1 in playerList: line = [] for player2 in playerList: line.append(Payoff(player1, player2)) table.append(line) return table payoff_table = array(GenPayoffTable(["I3","I4","I1"])) def SignalingGame(): """A simulation of the 'sender - receiver game'. """ # Open a window for graphics output. gfx = GfxDriver.Window(title = "Sender - Receiver Game") # Generate a dynamics function from the payoff table. dynFunc = Dynamics.GenDynamicsFunction(payoff_table, e=0.0,noise=0.0) # Set up a simplex diagram for showing the dynamics as a