import random XYZ = [1200,2000,2200] # These are the beginning assets of the three agents r = 2 # This is the % of poor agent assests exchanged in each transaction b = 60 # This is the probablity of a transaction favoring the wealthy XYZ_points = [] count = 0 for i in range(1000): Agent_pair = [] P = random.choice([[1,0,1],[1,1,0],[0,1,1]]) w = random.choice([0]*(100-b)+[1]*b) count = count + w Index = filter(lambda x:P[x] == 1,range(3)) if XYZ[Index[0]] < XYZ[Index[1]]: Wealth_rank = [Index[0],Index[1]] else: Wealth_rank = [Index[1],Index[0]] t = r * (0.01) * XYZ[Wealth_rank[0]] if w == 0: # Poor agent wins XYZ[Wealth_rank[0]] = XYZ[Wealth_rank[0]] + t XYZ[Wealth_rank[1]] = XYZ[Wealth_rank[1]] - t if w == 1: # Rich agent wins XYZ[Wealth_rank[1]] = XYZ[Wealth_rank[1]] + t XYZ[Wealth_rank[0]] = XYZ[Wealth_rank[0]] - t XYZ_points.append([(i,XYZ[0]),(i,XYZ[1]),(i,XYZ[2])]) X_points = map(lambda x:x[0],XYZ_points) Y_points = map(lambda x:x[1],XYZ_points) Z_points = map(lambda x:x[2],XYZ_points) point(X_points,rgbcolor = 'blue')+point(Y_points,rgbcolor = 'red')+point(Z_points,rgbcolor = 'green')