Exemplo n.º 1
0
def averagePathLength(graph):
    total = 0
    for v in graph.vertices():
        pf = PathFinder(graph, v)
        for w in graph.vertices():
            total += pf.distanceTo(w)
    return 1.0 * total / (graph.countV() * (graph.countV() - 1))
Exemplo n.º 2
0
    def reset(self, level=1):
        pygame.mixer.music.stop()
        pygame.mixer.music.play(10**8)
        self.menu = Menu()
        self.menu.add_button('Continue', (self.width // 2 - 150, 200),
                             target=self.open_menu)
        self.menu.add_button('Music', target=self.switch_music, switch=True)
        self.menu.add_button('Sounds', target=self.switch_sounds, switch=True)
        self.menu.add_button('Quit game', target=self.terminate)

        self.sprite_groups = {k: pygame.sprite.Group() for k in range(20, 30)}

        self.conditions = {k: False for k in range(40, 50)}
        self.conditions[RUNNING] = True
        self.conditions[FULLSCREEN] = True

        self.keys_pressed = []

        self.terrain = Terrain(16 * 3 * 3, 16 * 3 * 3, level)
        self.sprite_groups[CHUNKS] = pygame.sprite.Group(self.terrain.chunks)
        for chunk in self.sprite_groups[CHUNKS]:
            self.sprite_groups[ALL].add(chunk)
        self.screen2 = pygame.Surface((self.width, self.height),
                                      pygame.HWSURFACE, 32)
        self.player = Player(
            (self.sprite_groups[ENTITIES], self.sprite_groups[ALL]),
            (500, 500))
        self.camera = Camera(self.terrain.get_width(),
                             self.terrain.get_height(), self.player,
                             self.width // 2, self.height // 2)

        self.pathfinder = PathFinder(self.terrain.obst_grid)
        self.paths = dict()
        self.sprite_groups[PLAYER].add(self.player)
        self.camera.update()
Exemplo n.º 3
0
 def computePath(self, coord):
     pf = PathFinder(self.map.successors, self.map.move_cost,
                     self.map.move_cost)
     path_list = list(pf.compute_path(coord, self.goal))
     for i, path_coord in enumerate(path_list):
         next_i = i if i == len(path_list) - 1 else i + 1
         self.path_cache[path_coord] = path_list[next_i]
Exemplo n.º 4
0
def simulation():
    inputfile = ''
    c1 = 1
    c2 = 2
    delta = 4
    B = 0
    L = 0
    try:
        opt, args = getopt.getopt(sys.argv[1:], "f:c:d:v:l:h", ["help"])
    except:
        print("Invalid parameters!")
        sys.exit()
    for o, a in opt:
        if o == '-f':
            inputfile = a
        elif o == 'c':
            c1, c2 = map(float, a.split(','))
        elif o == '-d':
            try:
                d = float(a)
            except:
                print("invalid delta parameter!")
                sys.exit()
        elif o == '-v':
            try:
                B = float(a)
            except:
                print("Invalid speed specification!")
                sys.exit()
        elif o == '-l':
            try:
                L = float(a)
            except:
                print("Invalid time interval bound!")
                sys.exit()
        elif o in ['-h', '--help']:
            usage()
            sys.exit()
    # Get the optimum solution
    complete_graph = GraphGenerator(inputfile).getGraph()
    '''
	start = time.time()
	opt_alg = BFTSP(B)
	opt_weight, opt_path = opt_alg.opt(complete_graph)
	print("Optimal running time : ", time.time() - start)
	print("Optimal weight, " + str(opt_weight))
	print("Optimal path, " + ','.join(map(str,opt_path)))	
	'''
    # Get the approximate solution
    start = time.time()
    path_finder = PathFinder(complete_graph, c1, c2, B, L, delta)
    print("Approximate algorithm running time: ", time.time() - start)
    aprox_weight = path_finder.findPath()
    aprox_path = path_finder.path
    accumulate_weight = path_finder.block_weight
    print("Appoximate weight, " + str(aprox_weight))
    print("Approximate path, " + ','.join(map(str, aprox_path)))
    print("Accumulate weight, " + ','.join(map(str, accumulate_weight)))
Exemplo n.º 5
0
 def make_path_grid(self):
     # for our pathfinding, we're going to overlay a grid over the field with
     # squares that are sized by a constant in the config file
     origdim = (self.m_xmax_field, self.m_ymax_field)
     newdim = self.rescale_pt2path(origdim)
     self.m_pathgrid = GridMap(*self.rescale_pt2path((self.m_xmax_field,
                                                      self.m_ymax_field)))
     self.m_pathfinder = PathFinder(self.m_pathgrid.successors,
                                    self.m_pathgrid.move_cost,
                                    self.m_pathgrid.estimate)
Exemplo n.º 6
0
 def load_data(self):
     self.map = TiledMap("Images/til.tmx")
     self.transicio = ''
     self.pf = PathFinder(self.map)
     self.gchamp = pygame.sprite.Group()
     self.champ = champs.Champ2(np.true_divide(self.map.camera.size,2),conf.mides_champ)
     self.gchamp.add(self.champ)
     self.pressed_keys = []
     self.npcs = pygame.sprite.Group()
     self.z1 = zombie.Zombie(np.multiply(conf.tile_size,2))
Exemplo n.º 7
0
def main():
    main_square = PathFinder.get_all_coordinates_within_bounds(0, 0, 4, 4)
    lower_row = PathFinder.get_all_coordinates_within_bounds(1, -1, 3, -1)
    upper_row = PathFinder.get_all_coordinates_within_bounds(1, 5, 3, 5)
    available_coordinates = main_square + lower_row + upper_row
    duplicate_allowed_coordinates = lower_row + upper_row
    pf = PathFinder(available_coordinates, duplicate_allowed_coordinates, 3,
                    True, main_square)
    pf.generate_paths(Coordinate(2, 0), Coordinate(2, 4))
    print pf.get_shortest_path()
Exemplo n.º 8
0
def update_pars_and_pather(pars, pather, filename, **kwargs):
    if kwargs:
        pars = pars.copy()
        pars.update(kwargs)
        if pather is not None:
            warnings.warn("tensorstorer was given both a pather and kwargs. "
                          "Generating a new pather.")
    if kwargs or pather is None:
        # If kwargs, we need to make a pather to make sure that path
        # matches contents.
        pather = PathFinder(filename, pars)
    return pars, pather
Exemplo n.º 9
0
    def _recompute_path(self, map, start, end):
        pf = PathFinder(map.successors, map.move_cost, map.move_cost)
        t = time.clock()
        pathlines = list(pf.compute_path(start, end))

        dt = time.clock() - t
        if pathlines == []:
            print "No path found" 
            return pathlines
        else:
            print "Found path (length %d)" % len(pathlines)
            return pathlines
Exemplo n.º 10
0
    def _recompute_path(self, _map, start, end):
        pf = PathFinder(_map.successors, _map.move_cost, _map.move_cost)
        # t = time.process_time()
        pathlines = list(pf.compute_path(start, end))

        # dt = time.process_time() - t
        if pathlines == []:
            print("No path found")
            return pathlines
        else:
            print("Found path (length %d)" % len(pathlines))
            return pathlines
Exemplo n.º 11
0
 def _compute_path(self, coord):
     pf = PathFinder(self.map.successors, self.map.move_cost,
             self.map.move_cost)
     
     # Get the whole path from coord to the goal into a list,
     # and for each coord in the path write the next coord in
     # the path into the path cache
     #
     path_list = list(pf.compute_path(coord, self.goal))
     
     for i, path_coord in enumerate(path_list):
         next_i = i if i == len(path_list) - 1 else i + 1
         self._path_cache[path_coord] = path_list[next_i]
Exemplo n.º 12
0
    def analyze(self,
                carbon_only=True,
                use_antimotifs=True,
                draw_scenes=False):
        for line in util.parse_text_file("../rec/" + self.modules_file +
                                         ".txt"):
            if (line[0] == '@'):
                line = line[1:]
                self.pathfinder = PathFinder(carbon_only=carbon_only,
                                             pruning_method=None,
                                             ignore_chirality=False,
                                             use_antimotifs=use_antimotifs,
                                             outstream=self.logfile)
            else:
                self.pathfinder = PathFinder(carbon_only=carbon_only,
                                             pruning_method=None,
                                             ignore_chirality=True,
                                             use_antimotifs=use_antimotifs,
                                             outstream=self.logfile)

            pathway = line.split(';')
            self.find_modules(pathway, draw_scenes=draw_scenes)
            self.line_counter += 1
Exemplo n.º 13
0
def main():
    pars = parse()
    id_pars = get_tensor_id_pars(pars)
    filename = os.path.basename(__file__)
    pather = PathFinder(filename, id_pars)

    # - Infoprint -
    print("\n" + ("="*70) + "\n")
    print("Running %s with the following parameters:"%filename)
    for k,v in sorted(pars.items()):
        print("%s = %s"%(k, v))

    scaldims, c, momenta = get_scaldims(pars)
    scaldim_plot.plot_and_print(scaldims, c, pars, pather, momenta=momenta,
                                id_pars=id_pars)
    def _recompute_path(self):
        self.blocked_list = self.map.blocked

        pf = PathFinder(self.map.successors, self.map.move_cost,
                        self.map.move_cost)

        t = time.clock()
        self.path = list(pf.compute_path(self.start_pos, self.goal_pos))
        dt = time.clock() - t

        if self.path == []:
            self.msg1 = "No path found"
        else:
            self.msg1 = "Found path (length %d)" % len(self.path)

        self.msg2 = "Elapsed: %s seconds" % dt
        self.path_valid = True
Exemplo n.º 15
0
def main():
    pars = parse()
    id_pars = get_tensor_id_pars(pars)
    filename = os.path.basename(__file__)
    pather = PathFinder(filename, id_pars)

    # - Infoprint -
    print("\n" + ("=" * 70) + "\n")
    print("Running %s with the following parameters:" % filename)
    for k, v in sorted(pars.items()):
        print("%s = %s" % (k, v))

    maxi = 5
    leigs_by_theta = {}
    for g in np.linspace(*pars["gs"]):
        theta = np.arctan((1 - g) / (1 + g))

        eigs = get_eigs(pars, g=g)
        leigs = eigs.log()
        leigs *= -pars["block_width"] / (2 * np.pi)
        if pars["symmetry_tensors"]:
            leigs -= leigs[(0, )][0]
            for qnum, sect in leigs.sects.items():
                leigs[qnum] = sect[sect < maxi]
        else:
            leigs -= leigs[0]
            leigs = leigs[leigs < maxi]
        leigs_by_theta[theta] = leigs

    exacts_by_theta = {}
    exact_degs_by_theta = {}
    for g in {0, 1}:
        theta = np.arctan((1 - g) / (1 + g))
        prim_data = modeldata.get_primary_data(maxi * 2, pars, 0, g=g)
        exacts_by_theta[theta] = np.array(
            prim_data[0]) * (0.5 if g == 0 else 1)
        exact_degs_by_theta[theta] = prim_data[2]

    scaldim_plot.plot_dict(leigs_by_theta,
                           pars,
                           x_label=r"$\theta$",
                           exacts_dict=exacts_by_theta,
                           exact_degs_dict=exact_degs_by_theta,
                           y_label=r"$\Delta_\alpha(\theta)$",
                           id_pars=id_pars)
Exemplo n.º 16
0
def main():
    tStart = time.time()
    # print(sys.getrecursionlimit())
    # resource.setrlimit(resource.RLIMIT_STACK, [0x10000000, resource.RLIM_INFINITY])
    sys.setrecursionlimit(0x100000)
    # print(sys.getrecursionlimit())
    tMap = TMap("inputMaps\\Prob16Corner.test.txt")
    # tMap = TMap("inputMaps\\judge\\Prob16.in.txt")
    pathfinder = PathFinder(tMap.startNode, tMap)

    tFinish = time.time()
    tDif = (tFinish - tStart) * 1000 # execution time in ms

    # print(len(pathfinder.successfulPath)) # debugging
    for node in pathfinder.successfulPath: # debugging
        if node.char == " ": # debugging
            node.char = "O" # debugging
    print(tMap) # debugging

    print(f"\n\tsolution: {pathfinder.bestFound}\tInstances: {pathfinder.totalProcesses}")
    print(f"\texecution time: {round(tDif, 3)} ms")
Exemplo n.º 17
0
    pathfinder.plotPaths()


def computeAndDisplayDijkstra(pathfinder):
    path, time = pathfinder.computePathDijkstra()
    pathfinder.plotPaths()


def computeAndDisplayDFS(pathfinder):
    path, time = pathfinder.computePathDFS()
    pathfinder.displayEnv()


def computeAndDisplayBidirAStar(pathfinder):
    path, time = pathfinder.computePathBidirAStar()
    pathfinder.plotPaths()


def showComparisonPlots(pathfinder, test_samples):
    pathfinder_api.benchmark(test_samples, True, True)


if __name__ == "__main__":
    env = World(filename="worlds/colliders.csv")
    pathfinder_api = PathFinder(env)
    #pathfinder_api.displayEnvFigure()
    showComparisonPlots(pathfinder_api, 10)
    #computeAndDisplayDFS(pathfinder_api)
    #computeAndDisplayAStar(pathfinder_api)
    #computeAndDisplayDijkstra(pathfinder_api)
    #computeAndDisplayBidirAStar(pathfinder_api)
Exemplo n.º 18
0
def changepoint_path(wav_fn,
                     length,
                     graph=None,
                     markers=None,
                     sim_mat=None,
                     avg_duration=None,
                     APP_PATH=None,
                     nchangepoints=4,
                     min_start=None):
    """wave filename and graph from that wav, length in seconds"""
    # generate changepoints
    try:
        cpraw = subprocess.check_output([
            APP_PATH + 'music_changepoints/novelty', wav_fn, '64', 'rms',
            'euc',
            str(nchangepoints) * 3
        ])
        tmp_changepoints = [float(c) for c in cpraw.split('\n') if len(c) > 0]
        changepoints = []
        cp_idx = 0
        while len(changepoints) < nchangepoints:
            if min_start is None:
                changepoints.append(tmp_changepoints[cp_idx])
            elif tmp_changepoints[cp_idx] >= min_start:
                changepoints.append(tmp_changepoints[cp_idx])
            cp_idx += 1

    except:
        changepoints = novelty(wav_fn, k=64, nchangepoints=nchangepoints)

    print "Change points", changepoints

    if graph is not None:
        edge_lens = [graph[e[0]][e[1]]["duration"] for e in graph.edges_iter()]
        avg_duration = N.mean(edge_lens)
        nodes = sorted(graph.nodes(), key=float)
    else:
        nodes = map(str, markers)

    node_count = int(float(length) / avg_duration)

    closest_nodes = []
    node_to_cp = {}
    for cp in changepoints:
        closest_nodes.append(
            N.argmin([N.abs(float(node) - float(cp)) for node in nodes]))
        node_to_cp[str(closest_nodes[-1])] = cp

    out = []

    for pair in itertools.permutations(closest_nodes, r=2):
        # print "Finding path for pair", pair, "of length", node_count

        avoid_nodes = [cn for cn in closest_nodes if cn != pair[1]]
        # avoid_nodes = closest_nodes

        if graph is not None:
            try:
                shortest_path = nx.astar_path_length(graph, nodes[pair[0]],
                                                     nodes[pair[1]])
                # print "# shortest path:", shortest_path
                if shortest_path <= node_count:

                    pf = PathFinder(graph=graph,
                                    start=pair[0],
                                    end=pair[1],
                                    length=node_count)
                    res, cost = pf.find(avoid=avoid_nodes)
                    if res is not None:
                        out.append((res, cost))
                        break
            except:
                pass

        else:
            pf = PathFinder(start=pair[0],
                            sim_mat=sim_mat.copy(),
                            end=pair[1],
                            nodes=nodes,
                            length=node_count)
            res, cost = pf.find(avoid=avoid_nodes)
            if res is not None:
                out.append((res, cost, map(lambda x: node_to_cp[str(x)],
                                           pair)))

    return out, changepoints
Exemplo n.º 19
0
    def analyze_pairs(self,
                      carbon_only=True,
                      use_antimotifs=True,
                      max_distance=4):
        distances = [
        ]  # the minimal pathway length between the substrate and the product
        alternatives = [
        ]  # each value is the number of alternative pathways with the minimal distance

        line_counter = 0
        for line in util.parse_text_file("../rec/" + self.modules_file +
                                         ".txt"):
            if (line[0] == '@'):
                line = line[1:]
                self.pathfinder = PathFinder(carbon_only=carbon_only,
                                             pruning_method=None,
                                             ignore_chirality=False,
                                             use_antimotifs=use_antimotifs,
                                             outstream=self.logfile)
            else:
                self.pathfinder = PathFinder(carbon_only=carbon_only,
                                             pruning_method=None,
                                             ignore_chirality=True,
                                             use_antimotifs=use_antimotifs,
                                             outstream=self.logfile)

            (subs, prod, max_steps) = line.split(";", 2)
            if (max_steps in ['-1', 'inf', '']):
                sys.stdout.write(subs + " -(?)-> " + prod)
                sys.stdout.flush()
                (scenes,
                 dist) = self.get_shortest_pathways(subs, prod, max_distance)
            else:
                dist = int(max_steps)
                sys.stdout.write(subs + " -(%d)-> " % dist + prod)
                sys.stdout.flush()
                scenes = self.get_all_pathways(subs, prod, dist)

            if (dist == -1):
                sys.stdout.write(", Distance(L) = inf, N = 0\n")
                sys.stdout.flush()
                distances.append("inf")
                alternatives.append(0)
                self.html_writer.write(
                    "<li><span style=color:red>%s <-> %s (distance > %d)</span></li>\n"
                    % (subs, prod, self.max_module_size))
                self.html_writer.flush()
            else:
                sys.stdout.write(", Distance(L) = %d, N = %d\n" %
                                 (dist, len(scenes)))
                sys.stdout.flush()
                distances.append(dist)
                alternatives.append(len(scenes))
                self.html_writer.write(
                    "<li><span style=color:green>%s <-> %s (distance = %d)</span></li>\n"
                    % (subs, prod, dist))
                for i in range(len(scenes)):
                    self.html_writer.write("<li>")
                    self.html_writer.write_svg(
                        scenes[i], "pathologic_" + self.experiment_name +
                        "/pair%d_path%d" % (line_counter, i))
                    self.html_writer.write("</li>\n")
                self.html_writer.flush()
            line_counter += 1

        result_file = open("../results/" + self.experiment_name + ".txt", "w")
        result_file.write(str(distances) + "\n" + str(alternatives) + "\n")
        result_file.close()
Exemplo n.º 20
0
# These are parameters that affect the way the search graph works.
# It if probably best not to change them.
use_antimotifs = False
carbon_only = True
ignore_chirality = False
max_depth = 2
reaction_database_fname = "../rec/reaction_templates.dat"

# the substrate and product must be listed in '../metacyc/mcard_sdf_extra.txt'
# which uses the MOL format for describing molecules.
# each one of them can also be a sum of more than one compound (i.e. ribitol + CO2)
substrate, product = 'D-ribulose-5P', 'L-ribulose-5P'

pathfinder = PathFinder(carbon_only=True,
                        pruning_method=None,
                        ignore_chirality=ignore_chirality,
                        use_antimotifs=True,
                        reaction_database_fname=reaction_database_fname)

# This loop tries to find all the paths with lengths less than 'max_depth'
for depth in xrange(1, max_depth + 1):
    sys.stderr.write(substrate + " <=> " + product +
                     ", depth = %d ... " % depth)
    G_subs = compound2graph(substrate)
    G_prod = compound2graph(product)
    (original_compound_map, possible_paths,
     D) = pathfinder.find_shortest_pathway([G_subs], [G_prod],
                                           max_levels=depth)

    for (substrate_pathways, product_pathways, h_bridge) in possible_paths:
        # the results are given as 3-tuples, characterized by the compound where the two ends
Exemplo n.º 21
0
# Accept a file name, a delimiter, and a source vertex as command-line
# arguments. Build a graph from the file, assuming that each line of
# the file specified a vertex and a list of vertices connected to that
# vertex, separated by the delimiter. Then repeatedly read a
# destination vertex from standard input, and write the shortest path
# from the source index to the destination index.

ommand-line arguments file, delimiter, and s. The file 
# contains a graph expressed using delimiter Read data from
# file to create a graph
file = sys.argv[1]
delimiter = sys.argv[2]
s = sys.argv[3]

graph = Graph(file, delimiter)
pf = PathFinder(graph, s)

while stdio.hasNextLine():
    t = stdio.readLine()
    if pf.hasPathTo(t):
        distance = pf.distanceTo(t)
        for v in pf.pathTo(t):
            stdio.writeln('   ' + v)
        stdio.writeln('distance: ' + str(distance))

#-----------------------------------------------------------------------

# python separation.py routes.txt " " JFK
# LAX   
#    JFK
#    ORD
Exemplo n.º 22
0
from psutil import Process, wait_procs

from definitions import BlizzardGame
from pathfinder import PathFinder
from consts import SYSTEM

pathfinder = PathFinder(SYSTEM)


class InstalledGame(object):
    def __init__(self, info: BlizzardGame, uninstall_tag: str, version: str,
                 last_played: str, install_path: str):
        self.info = info
        self.uninstall_tag = uninstall_tag
        self.version = version
        self.last_played = last_played
        self.install_path = install_path

        self.execs = pathfinder.find_executables(self.install_path)
        self._processes = set()

    @property
    def local_game_args(self):
        return (self.info.blizzard_id, self.is_running)

    @property
    def playable(self):
        if self.version != '':
            return True

    def add_process(self, process: Process):
Exemplo n.º 23
0
        timer.print_elapsed()
        if pars["save_scaldim_file"]:
            write_tensor_file(data=res,
                              prefix="scals_by_alpha",
                              pars=id_pars,
                              filename=filename)
    return res


#=============================================================================#

if __name__ == "__main__":
    pars = parse()
    id_pars = get_id_pars(pars)
    filename = os.path.basename(__file__)
    pather = PathFinder(filename, id_pars)

    # - Infoprint -
    print("\n" + ("=" * 70) + "\n")
    print("Running %s with the following parameters:" % filename)
    for k, v in sorted(pars.items()):
        print("%s = %s" % (k, v))

    res = load_cft_data(pars)
    scaldims_by_alpha, c = res[:2]
    if pars["do_momenta"]:
        momenta_by_alpha = res[2]
    else:
        momenta_by_alpha = None

    scaldim_plot.plot_and_print_dict(scaldims_by_alpha,
Exemplo n.º 24
0
 def _assignTask(self, task):
     print(type(task))
     pickup, drop = (task["pickup"]["x"], task["pickup"]["y"]), (
         task["drop"]["x"],
         task["drop"]["y"],
     )
     print(pickup, drop)
     for i in range(len(self.robots)):
         if not self.robots[i].busy:
             print("Angle = ", self.robots[i].getAngle())
             self.robots[i].makeBusy(task)
             self.mutex.release()
             task["robot"] = self.robots[i].id
             self.socketio.emit("assignTo", {
                 "uuid": task["uuid"],
                 "robot": self.robots[i].id
             })
             task["status"] = "Computing Path"
             self.socketio.emit("updateStatus", {
                 "uuid": task["uuid"],
                 "status": "Computing Path"
             })
             finder = PathFinder(self.warehouse)
             _, pos = sim.simxGetObjectPosition(
                 self.warehouse.client,
                 self.robots[i].base,
                 -1,
                 sim.simx_opmode_blocking,
             )
             start = self.warehouse.warehouse_to_img(pos[0], pos[1])
             pickupPathImg, pickupPath = finder.find(
                 start, pickup, self.robots[i].getAngle())
             print("pick found")
             if len(pickupPath) == 0:
                 print("No")
                 task["status"] = "No route"
                 self.socketio.emit("updateStatus", {
                     "uuid": task["uuid"],
                     "status": task["status"]
                 })
                 self.release(i)
                 return
             dropPathImg, dropPath = finder.find(pickup, drop)
             print("drop found")
             if len(dropPath) == 0:
                 print("No")
                 task["status"] = "No route"
                 self.socketio.emit("updateStatus", {
                     "uuid": task["uuid"],
                     "status": task["status"]
                 })
                 self.release(i)
                 return
             task["pickupPath"] = pickupPathImg
             task["dropPath"] = dropPathImg
             self.socketio.emit(
                 "path",
                 {
                     "uuid": task["uuid"],
                     "pickup": pickupPathImg,
                     "drop": dropPathImg,
                 },
             )
             task["status"] = "In Transit"
             self.socketio.emit("updateStatus", {
                 "uuid": task["uuid"],
                 "status": "In Transit"
             })
             print(task["package"]["id"])
             tracker = PathTracker(
                 pickupPath,
                 dropPath,
                 2.8,
                 5,
                 self.robots[i],
                 self.warehouse,
                 self.socketio,
                 task["package"]["id"],
             )
             tracker.track()
             curPos = self.robots[i].getPos()
             mappedPos = self.warehouse.warehouse_to_img(
                 curPos[0], curPos[1])
             self.robots[i].task["status"] = "Finished"
             self.socketio.emit(
                 "updateStatus",
                 {
                     "uuid": self.robots[i].task["uuid"],
                     "status": "Finished"
                 },
             )
             self.socketio.emit(
                 "updateRobotPos",
                 {
                     "id": self.robots[i].id,
                     "x": mappedPos[0],
                     "y": mappedPos[1]
                 },
             )
             self.release(i)
             return
from pathfinder import ElevationMap, MapImage, PathFinder

map = ElevationMap()
map_image = MapImage()
pathfinder = PathFinder()

def test_get_max():
    assert map.get_max() == 4750

def test_get_min():
    assert map.get_min() == 4691

# def test_greyify():
#     assert map_image.greyify() == [ [99, 99, 99, 99], 
#                                     [99, 99, 99, 99], 
#                                     [99, 99, 99, 99], 
#                                     [100, 99, 99, 99]]

def test_navigate():
    assert pathfinder.navigate() == (4740, 0, 1)
    

def test_get_current():
    assert pathfinder.current_location == (4750, 0, 0)

def test_get_north():
    assert pathfinder.get_north_location() == None

def test_get_south():
    assert pathfinder.get_south_location() == (4708, 1, 1)