def move_walker(mas, env, pop, walker, l_pos, env_size): """ Makes the walker move to the pos_cell position. """ pos_cell = get_pos(walker) if len(l_pos) > 0 and m.get_cycle(mas) % 2 == 0: pos_cell = l_pos[randrange(len(l_pos))] pos_cell = unital_move(env, env_size, walker, pos_cell) elif (len(l_pos) == 0 and m.get_cycle(mas) % 2 == 0) or (m.get_cycle(mas) % 2 == 0 and get_pos(walker) == pos_cell): pos_cell = try_to_move(walker, pos_cell, env, env_size) replace_walker(env, pop, walker, pos_cell)
def tki_experiment_loop(mas): cycle = m.get_cycle(mas) canvas.delete(tk.ALL) # Clear the canvas __draw_mas(canvas, mas, cell_size) pop = m.get_pop(mas) canvas.create_text(MARGIN, MARGIN, anchor=tk.NW, text="Cycle #" + str(cycle)) if not ending_condition(mas): m.increment_cycle(mas) m.run_one_cycle(mas,config) app.update() app.after(TIME_OF_FRAME, tki_experiment_loop, mas)
def tki_experiment_loop(mas): cycle = m.get_cycle(mas) canvas.delete(tk.ALL) # Clear the canvas __draw_mas(canvas, mas, cell_size) pop = m.get_pop(mas) canvas.create_text(MARGIN, MARGIN, anchor=tk.NW, text="Cycle #" + str(cycle)) if not ending_condition(mas): m.increment_cycle(mas) m.run_one_cycle(mas) app.update() app.after(TIME_OF_FRAME, tki_experiment_loop, mas)
def tki_experiment_loop(mas): cycle = m.get_cycle(mas) canvas.delete(tk.ALL) # Clear the canvas __draw_mas(canvas, mas, cell_size) pop = m.get_pop(mas) canvas.create_text(MARGIN, MARGIN, anchor=tk.NW, text="Cycle #" + str(cycle)) male,female = p.get_agents_alive_by_sex(pop) canvas.create_text(MARGIN, MARGIN-15, anchor=tk.NW, text="Population #" + str(male+female)) canvas.create_text(MARGIN+100, MARGIN, anchor=tk.NW, text="Femme #" + str(female)) canvas.create_oval(MARGIN+180,MARGIN-4,MARGIN+188,MARGIN-12,fill='black') canvas.create_text(MARGIN+100, MARGIN-15, anchor=tk.NW, text="Homme #" + str(male)) canvas.create_oval(MARGIN+180,MARGIN+3,MARGIN+188,MARGIN+11,fill='red') canvas.create_text(MARGIN+200, MARGIN,anchor=tk.NW, text="Dead agents #" + str(p.get_dead_agents(pop))) if not eval("m."+ending_condition+"(mas)"): m.increment_cycle(mas) m.run_one_cycle(mas) app.update() app.after(TIME_OF_FRAME, tki_experiment_loop, mas)
def tki_experiment_loop(mas): cycle = m.get_cycle(mas) canvas.delete(tk.ALL) # Clear the canvas __draw_mas(canvas, mas, cell_size) pop = m.get_pop(mas) canvas.create_text(MARGIN, MARGIN, anchor=tk.NW, text="Cycle #" + str(cycle)) male, female = p.get_agents_alive_by_sex(pop) canvas.create_text(MARGIN, MARGIN - 15, anchor=tk.NW, text="Population #" + str(male + female)) canvas.create_text(MARGIN + 100, MARGIN, anchor=tk.NW, text="Femme #" + str(female)) canvas.create_oval(MARGIN + 180, MARGIN - 4, MARGIN + 188, MARGIN - 12, fill='black') canvas.create_text(MARGIN + 100, MARGIN - 15, anchor=tk.NW, text="Homme #" + str(male)) canvas.create_oval(MARGIN + 180, MARGIN + 3, MARGIN + 188, MARGIN + 11, fill='red') canvas.create_text(MARGIN + 200, MARGIN, anchor=tk.NW, text="Dead agents #" + str(p.get_dead_agents(pop))) if not eval("m." + ending_condition + "(mas)"): m.increment_cycle(mas) m.run_one_cycle(mas) app.update() app.after(TIME_OF_FRAME, tki_experiment_loop, mas)