Ejemplo n.º 1
0
def solve(): 
    """ gets the start and end coordinates from the request, loads the last
    generated map from the database and calls the pathfinder algorithm. The
    result of a list of coordinates are serialized as JSON and passed to the
    browser for rendering. """
    
    sx = request.args.get('sx','')
    sy = request.args.get('sy','')
    dx = request.args.get('dx','')
    dy = request.args.get('dy','')
    sx = processinput(sx)
    sy = processinput(sy)
    dx = processinput(dx)
    dy = processinput(dy)

    generatedmap = get_map()

    if generatedmap != None:

        path = find(generatedmap.mapdata, 
                generatedmap.width, 
                generatedmap.height, [sx, sy], [dx,dy])
        return json.dumps(path)

    return "[]"
Ejemplo n.º 2
0
def solve():
    sx = request.args.get('sx','')
    sy = request.args.get('sy','')
    dx = request.args.get('dx','')
    dy = request.args.get('dy','')
    sx = processinput(sx)
    sy = processinput(sy)
    dx = processinput(dx)
    dy = processinput(dy)

    generatedmap = get_map()

    if generatedmap != None:

        path = find(generatedmap.mapdata, 
                generatedmap.width, 
                generatedmap.height, [sx, sy], [dx,dy])
        return json.dumps(path)

    return "[]"