コード例 #1
0
ファイル: flask_app.py プロジェクト: CfTO/hackbikeshareTO
def walkPath():
	# Read in Arguments
	start = request.args.get('origin')
	end = request.args.get('dest')
	if start is None:
		start = '633 Bay St, Toronto ON'
	if end is None:
		end = '633 Bay St, Toronto ON'
	return jsonify ( directions(start, end, 'walking') );
コード例 #2
0
ファイル: flask_app.py プロジェクト: hassanis/hackbikeshareTO
def walkPath():
    # Read in Arguments
    start = request.args.get('origin')
    end = request.args.get('dest')
    if start is None:
        start = '633 Bay St, Toronto ON'
    if end is None:
        end = '633 Bay St, Toronto ON'
    return jsonify(directions(start, end, 'walking'))
コード例 #3
0
def init(datas):
    source = conversionData[datas[0]]
    dest = conversionData[datas[1]]
    robo1 = conversionData[datas[2]]
    robo2 = conversionData[datas[3]]
    robo = [robo1, robo2]
    src_dest = tracer(source, dest)
    source_to_dest = (gen for gen in src_dest)

    pre = next(source_to_dest)
    nex = next(source_to_dest)
    diff = tuple(numpy.subtract(pre, nex))

    path = [[pre, nex]]
    i = 0

    pre = nex

    while (True):
        try:
            nex = next(source_to_dest)
        except:
            break
        if diff == tuple(numpy.subtract(pre, nex)):
            path[i].append(nex)
        else:
            i += 1
            diff = tuple(numpy.subtract(pre, nex))
            path.append([pre])
            path[i].append(nex)
        pre = nex

    for i in range(len(path)):
        prevNode = tuple(
            numpy.add(numpy.subtract(path[i][0], path[i][1]), path[i][0]))
        toChange = []
        toChange.append(path[i][0])
        for r in robo:
            if r != robo[i]:
                toChange.append(r)
        MAP = updateMap(toChange)
        temp = tracer(robo[i], prevNode)
        if temp == []:
            print("Not Possible")
            break
        temp += path[i]
        # print("Path for Robo" + str(i))
        # print(temp)
        robo[i] = temp[-2]
        source = temp[-1]
        swarmPaths.append(temp)
        swarmDirecs.append(' '.join(directions(temp)))
    swarmPaths.append(src_dest)
    return swarmPaths, swarmDirecs
コード例 #4
0
import requests, json
from directions import directions

obj = directions("633 Bay St, Toronto ON", "45 Ulster, Toronto ON", 'walking')

print(obj)
コード例 #5
0
import requests, json
from directions import directions

obj = directions("633 Bay St, Toronto ON", "45 Ulster, Toronto ON",'walking');

print(obj)
コード例 #6
0
ファイル: board.py プロジェクト: remindjp/MATH-480-SAGE
    def move(self, turn, moves, ai = True, plots = False, plot_every = True):

        if not ai:
            x = int(raw_input("row:"))
            y = int(raw_input("col:"))
        else:
            x = random.randint(0,18)
            y = random.randint(0,18)
            print "turn # = " + str(turn)
            
        id = 19 * x + y
        while self.board[id] != -1: # while not placing on empty
            if not ai:
                x = int(raw_input("row:"))
                y = int(raw_input("col:"))
            else:
                x = random.randint(0,18)
                y = random.randint(0,18)

            id = 19 * x + y
            
      
        #ko, 1 member set
        for piece in self.ko_piece:
            self.board[piece] = -1
        self.ko_piece.clear()
        

        #creates a new group for each new move
        self.board_groups[id] = power_group(id, turn, self.board, self.board_groups, \
            self.master_set, self.ko_piece, self.black_caps, self.white_caps)
        
        self.board[id] = turn
        self.master_set.add(self.board_groups[id])
        directions.directions(id, self.board_groups[id].verify_enemy_dead)
        
   
        self.value_update(x,y,turn, moves, plot_every)

        if plot_every or turn == moves:
            #prints board    
            for j in xrange(self.size):
                for i in xrange(self.size):
                    print str(self.board[j * 19 + i]),
                print " "
            print " "
    
            for j in xrange(self.size):
                for i in xrange(self.size):
                    print str(self.board_groups[j * 19 + i]),
                print " "
            print " "
 
#prints liberties using heat graph

        colors = [0 for x in xrange(self.size*self.size)]

        for member in self.board_groups:
            if isinstance(member, power_group):
                for liberty in member.liberties:
                    if member.turn % 2 ==0:
                        colors[liberty] = -2
                    else:
                        colors[liberty] = -1
                        
        self.heat_graph(colors, 'alexnoob2.png', 1, 's', 300)         
コード例 #7
0
                # check if it is in open list
                # if it is in open list compare and replace if it is better
                # if it is not in open list, add it and details
                if ((cellDetails[parent[1] + neighbours[i][0]][parent[2] + neighbours[i][1]]['f'] == float('inf')) or (cellDetails[parent[1] + neighbours[i][0]][parent[2] + neighbours[i][1]]['f'] > newF)):
                    openList.append([newF, parent[1] + neighbours[i][0], parent[2] + neighbours[i][1]])
                    cellDetails[parent[1] + neighbours[i][0]][parent[2] + neighbours[i][1]]['f'] = newF
                    cellDetails[parent[1] + neighbours[i][0]][parent[2] + neighbours[i][1]]['g'] = newG
                    cellDetails[parent[1] + neighbours[i][0]][parent[2] + neighbours[i][1]]['h'] = newH
                    cellDetails[parent[1] + neighbours[i][0]][parent[2] + neighbours[i][1]]['PX'] = parent[1]
                    cellDetails[parent[1] + neighbours[i][0]][parent[2] + neighbours[i][1]]['PY'] = parent[2]

# Tracing the path   
tracedPath = [(SX, SY), (DX, DY)]                 
if not destinationFound:
    print("Sorry, couldnot find the destination")
else:
    print("\nThe path is\n")
    row = cellDetails[DX][DY]['PX']
    col = cellDetails[DX][DY]['PY']
    while(not (row == SX and col == SY)):
        tracedPath.insert(1, (row, col))
        x = cellDetails[row][col]['PX']
        y = cellDetails[row][col]['PY']
        row, col = x, y
    
# print(*tracedPath)

from directions import directions

print(directions(tracedPath))
コード例 #8
0
#!/usr/bin/python
import readline
import json
import goog_shell
import directions
import os
instructions = directions.directions()
shell = goog_shell.goog_shell()

print " 'h' for available options "
print " 'see'  for examples "
print " 'exit' to quit"

while True:
    try:
        readline.parse_and_bind("tab: complete")
        readline.set_completer(shell.complete)
        user_command = raw_input('>> ')
        tokenized = user_command.split()
        token_one = user_command.split()[0]
        if token_one == 'h':
            instructions.help_goog()
        if token_one == "see":
            instructions.see()
        if token_one == "ls":
            shell.list_directory()
        if token_one == "clear":
            os.system('clear')
        if token_one == "cd":
            if len(user_command.split()) < 2:
                shell.change_directory('root')
コード例 #9
0
if __name__ == "__main__":
    # Parse settings file
    api_key, origin, dest = load_settings("../settings.json")

    # Create client object
    client = Client(key=api_key)

    # Get response
    rsp = directions(client,
                     origin,
                     dest,
                     mode="transit",
                     waypoints=None,
                     alternatives=False,
                     avoid=None,
                     language=None,
                     units="metric",
                     region=None,
                     departure_time=None,
                     arrival_time=None,
                     optimize_waypoints=False,
                     transit_mode=None,
                     transit_routing_preference=None,
                     traffic_model=None)

    parsed = json.loads(json.dumps(rsp, sort_keys=False, indent=4))[0]
    print(json.dumps(parsed, sort_keys=False, indent=4))

    # Run server
    from sys import argv

    if len(argv) == 2:
コード例 #10
0
# export FLASK_APP=app.py && python3 -m flask run

from directions import directions as directions
from locations_selectable import selectable_locations_dict as locations_dict
from locations_selectable import selectable_locations_list as locations_list
from flask import Flask

# # Users need to see locations_dict.values() i.e. locations_list, but locations_dict.keys() has to be inputted to the algorithm
# locations_dict = locations_dict()
# locations_list = locations_list()
# print(locations_dict)
# print(f"\n\n")
# print(locations_list)

# Testing algorithm
print(directions("becc", "coleman"))
print(f"\n")
print(directions("woodland_10", "trim"))
print(f"\n")
print(directions("forest", "tomasso"))

app = Flask(__name__)