from django.shortcuts import render, render_to_response
from models import Agent
from models import parse_locations
from astar import shortest_path

def index(request):
    a = Agent(parse_locations("coordenadas.txt"))
    a.distance_calc()
    a.build_graph()

    h = lambda c1, c2: a.matrix_distance[c1][c2] * 0.7 + float(a.locations[c1]['rating']) * 0.3

    path = shortest_path(a.graph, 8, 4, h)

    #return render_to_response(request,'index.html',{"list": path})
    return render(request, 'index.html', {"list" : path})
