コード例 #1
0
ファイル: tsp.py プロジェクト: bpulling21/Heuristic-Project
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
ファイル: knight_tour.py プロジェクト: jessicaohy/games
# 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"