bg=CANVAS_BACKGROUND_COLOUR) canvas.pack() ############################################################################### # TODO: If the robot is set to the edge of the screen the search values will # overlap (like snake or something bleeding over). Also when this happens teh # reset method doesn't work. # Position for the robot to start at while testing robot_tuple = (35,20) test_graph = Graph(NODE_NUM_H, NODE_NUM_W, NODE_SIZE, canvas) test_graph.render() test_graph.place_robot(robot_tuple) ############################################################################### def reset_values(t, b, r): """Takes input of top and bottom tuples for the search graph and resets them to the robot position. """ t = (r[0], r[1]) b = (r[0], r[1]) return t, b def calc_tb_distance(t, b): """Input of tuples t[op] and b[ottom] nodes, returns half the distance between the two
# CREATE MAIN TKINTER ROOT root = Tk() canvas = Canvas(root, width=G.canvas_width, height=G.canvas_height, bg=G.canvas_background_colour) canvas.pack() # create a graph instance simulation_graph = Graph(G.matrix_size, G.matrix_size, G.node_size, canvas) G.random_robot_start_position() simulation_graph.render() simulation_graph.place_robot(G.robot_start_position) ############################################################################### # robot and item_node positions start_pos = G.robot_start_position # TODO: This is how many items want to be found by the program. if this is set # to 1 then only one item is found, if it's set to 4 then 4 will be found etc. items_to_find = 10 # initial set with the one element which is the robot # seeker_set = set() # set that will contain the items that have been found (if any) on that # particular search item_found = set()
canvas = Canvas(root, width = G.canvas_width, height = G.canvas_height, bg=G.canvas_background_colour) canvas.pack() # create a graph instance simulation_graph = Graph(G.matrix_size, G.matrix_size, G.node_size, canvas) G.random_robot_start_position() simulation_graph.render() simulation_graph.place_robot(G.robot_start_position) ############################################################################### # robot and item_node positions start_pos = G.robot_start_position # TODO: This is how many items want to be found by the program. if this is set # to 1 then only one item is found, if it's set to 4 then 4 will be found etc. items_to_find = 10 # initial set with the one element which is the robot # seeker_set = set() # set that will contain the items that have been found (if any) on that # particular search item_found = set()
bg=CANVAS_BACKGROUND_COLOUR) canvas.pack() ############################################################################### # TODO: If the robot is set to the edge of the screen the search values will # overlap (like snake or something bleeding over). Also when this happens teh # reset method doesn't work. # Position for the robot to start at while testing robot_tuple = (35, 20) test_graph = Graph(NODE_NUM_H, NODE_NUM_W, NODE_SIZE, canvas) test_graph.render() test_graph.place_robot(robot_tuple) ############################################################################### def reset_values(t, b, r): """Takes input of top and bottom tuples for the search graph and resets them to the robot position. """ t = (r[0], r[1]) b = (r[0], r[1]) return t, b def calc_tb_distance(t, b):