import random import operator import matplotlib.pyplot agents = [] agents.append([random.randint(0,99),random.randint(0,99)]) if random.random() < 0.5: agents[0][0] += 1 else: agents[0][0] -= 1 if random.random() < 0.5: agents[0][1] += 1 else: agents[0][1] -= 1 if random.random() < 0.5: agents[0][0] += 1 else: agents[0][0] -= 1 if random.random() < 0.6: agents[0][1] += 1 else: agents[0][1] -= 1 print(agents[0][0], agents[0][1]) agents.append([random.randint(0,99), random.randint(0,99)]) if random.random() > 0.5: agents[1][0] += 1 else: agents[1][0] -= 1 if random.random() < 0.5: agents[1][1] += 1 else: agents[1][1] -= 1 if random.random() < 0.5: agents[1][0] += 1 else: agents[1][0] -= 1 if random.random() < 0.5: agents[1][1] -= 1 else: agents[1][1] -= 1 print(agents[1][0], agents[1][1]) answer = (((agents[0][0] - agents[1][0])**2) + ((agents[1][0] - agents[1][1])**2))**0.5 print(answer) print(max(agents, key=operator.itemgetter(1))) matplotlib.pyplot.ylim(0, 99) matplotlib.pyplot.xlim(0, 99) matplotlib.pyplot.scatter(agents[0][1],agents[0][0]) matplotlib.pyplot.scatter(agents[1][1],agents[1][0]) m = max(agents, key=operator.itemgetter(1)) matplotlib.pyplot.scatter(m[1],m[0], color='red') matplotlib.pyplot.show()