Пример #1
0
def main():
    # Load Data
    point_data = open('tsp1000.txt', 'r')
    dimensions = point_data.readline().split()
    width = float(dimensions[0])
    height = float(dimensions[1])

    # data is a 2D storing all points from the input file
    data = []
    for line in point_data:
        data.append(line.split())
        
    # Create a tour object
    my_tour = tour.Tour()

    # Insert the points into the tour
    for location in data:
        # Offset for Turtle drawing
        pt = tour.Point(float(location[0]) - width / 2, float(location[1]) - height / 2)
        my_tour.insert_smallest(pt) # Can alternatively call insert_smallest

    # Draw the tour on the screen
    screen = turtle.Screen()
    screen.setup(900, 900)
    t = turtle.Turtle()
    t.speed(0)
    t.hideturtle()

    my_tour.draw(t)

    # Report the results
    print('Tour length: ' + str(my_tour.get_length()))    
    print('Number of points: ' + str(my_tour.get_size()))

    turtle.mainloop()
Пример #2
0
 def __init__(self):
     self.tour = t.Tour()
     self.cases = []
     self.collide = []
     self.arbres = []
     self.posArbres = []
     self.ressorts = []
Пример #3
0
 def get_tour(self, tourname, description=""):
     """Returns a tour. If the tour doens't exist, it will create a new one.
     
     Parameters:
     tourname: the name to give to this tour
     description: an optional description
     
     Returns:
     an instance of tour.Tour
     """
     return tour.Tour(tourname, self, description)
Пример #4
0
 def __init__(self, parent=None):
     QtWidgets.QWidget.__init__(self, parent)
     self.ui = Ui_MainWindow()
     tours = [tour.Tour(12, 3), tour.Tour(12, 2), tour.Tour(12, 6)]
     self.ui.setupUi(self, tours)
Пример #5
0
# Jessica Oh Hui Yu

import tour


class invalidInput(Exception):
    pass


chessboardList = tour.Tour(
)  # creating a list (object) representing a chessboard

print(" ############ M E N U ##############")
print("1. Start")
print("2. Position")
print("3. Undo")
print("4. Save")
print("5. Restore")
print("6. Quit")
option = int(input("Enter choice (number): "))

while (option != 6):

    ## start ##
    if (option == 1):
        chessboardList.clear_board()
        chessboardList.create_chessboardList()

        coordinates = input(
            "Enter position for knight to move to (row(0-7)_col(0-7)]): ")
        coordinates = coordinates.split(
Пример #6
0
import tour
import display
from datetime import datetime

app = Flask(__name__, template_folder = './static')
drawFunc = draw.draw()

views = Blueprint('view_routes', __name__)
#Displays html page
@views.route("/display")
def home():
    return render_template('main.html')

app.register_blueprint(views)

lp = tour.Tour()

data = Blueprint('data_routes', __name__)
#Called when there is a query request. 
	#Inputs parameters and file names
	#Outputs the OD data
@data.route("/run/OD", methods=['POST'])
def getOD():
	param = request.json
	if not (param['sFile'] or param['lFile']) or param['zFile']:
		param['sFile'] = 'sample.csv'
		param['lFile'] = 'manhattan_locations.csv'
		param['zFile'] = 'manhattan_zones.csv'
	start = None
	end = None
	st = "00:00"