#matplotlib.pyplot.imshow(environment)
#matplotlib.pyplot.show()

num_of_agents = 10
num_of_iterations = 100
neighbourhood = 200

# Make the empty graph
fig = matplotlib.pyplot.figure(figsize=(7, 7))
ax = fig.add_axes([0, 0, 1, 1])

# make agents
agents = []
for i in range(num_of_agents):
    #random_seed += 1
    agents.append(agentframework5.Agent(environment, agents))

carry_on = True

if random.random() < 0.1:
    carry_on = False
    print("stopping condition")


def update(frame_number):

    #print (agents[i])
    fig.clear()
    '''   
    # Move the agents.
    for j in range(num_of_iterations):
Exemplo n.º 2
0

# Calculate the distance between agents
def distance_between(agents_row_a, agents_row_b):
    return (((agents_row_a.x - agents_row_b.x)**2) +
            ((agents_row_a.y - agents_row_b.y)**2))**0.5


# Create list of agents
agents = []
num_of_agents = 10
num_of_iterations = 100

# Create agents
for i in range(num_of_agents):
    agents.append(agentframework5.Agent())

# Move agents
for j in range(num_of_iterations):
    for i in range(num_of_agents):
        agents[i].move()

# Draw and print the graph
matplotlib.pyplot.ylim(0, 100)
matplotlib.pyplot.xlim(0, 100)

for i in range(num_of_agents):
    matplotlib.pyplot.scatter(agents[i].x, agents[i].y)

matplotlib.pyplot.show()
Exemplo n.º 3
0
number_of_agents = 10
agentslist = []
distances = []


def distance_between(agents_row_a, agents_row_b):
    return (((agents_row_a._x - agents_row_b._x)**2 +
             (agents_row_a._y - agents_row_b._y)**2)**0.5)


print("Number of agents", number_of_agents)
'''
Generate <number_of_agents> instances of class <Agent>
'''
for i in range(number_of_agents):
    agentslist.append(af.Agent())
#print("Type of Agent",type(agentlist[0])
'''
Moving Agents <number_of_moves> times
'''

for j in range(number_of_moves):
    for i in range(0, number_of_agents):
        agentslist[i].move()
'''
Plotting agents
'''
matplotlib.pyplot.ylim(0, 99)
matplotlib.pyplot.xlim(0, 99)
for i in range(number_of_agents):
    matplotlib.pyplot.scatter(agentslist[i]._x, agentslist[i]._y)
Exemplo n.º 4
0
agents = []
#set number of agents to 10
num_of_agents = 10
#set number of agent moves TO 100
num_of_iterations = 100
#set neighbourhood
neighbourhood = 20
#
fig = matplotlib.pyplot.figure(figsize=(7, 7))
ax = fig.add_axes([0, 0, 1, 1])
#ax.set_autoscale_on(False)
#1.2 START LOCATION & ENVIRONMENT- for each agent in 'num_of_agents' assigned coordinates, and attach environment, and a list of agents using agentframework module and Agent class and a list of agents
for i in range(num_of_agents):
    y = int(td_ys[i].text)
    x = int(td_xs[i].text)
    agents.append(agentframework.Agent(environment, agents, y, x))
# print another agents x loc
print("agent 1 x =", agents[0].agents[1].x)

#2. MOVE AGENTS
carry_on = True


def update(frame_number):

    fig.clear()

    global carry_on
    #for j in range (num_of_iterations):
    #    print("iteration # = ", j)
    if carry_on: