gt2_cheat_sheet

Globetrotter 2 Cheat Sheet
Log | Files | Refs | README

commit 06b69fb77a62480be087413c8ab192973697ea78
Author: sej <sej@sejdt.localhost>
Date:   Thu, 10 Oct 2024 14:51:37 +0200

Initial commit

Diffstat:
A.gitignore | 2++
Agenhtml.py | 35+++++++++++++++++++++++++++++++++++
Agt2.py | 422+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aprice_functions.ggb | 0
Atemplates/base.html | 15+++++++++++++++
Atemplates/con.html | 30++++++++++++++++++++++++++++++
Atemplates/index.html | 20++++++++++++++++++++
7 files changed, 524 insertions(+), 0 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -0,0 +1,2 @@ +__pycache__ +html diff --git a/genhtml.py b/genhtml.py @@ -0,0 +1,35 @@ +#!/usr/bin/env python3 +import gt2 +from jinja2 import Environment, PackageLoader, select_autoescape +import os + +if __name__ == "__main__": + + env = Environment( + loader=PackageLoader( "genhtml", package_path="templates" ), + autoescape=select_autoescape() + ) + + index = env.get_template( "index.html" ) + con = env.get_template( "con.html" ) + + headers = [ gt2.c[i][0] for i in range( len( gt2.c ) ) ] + + os.makedirs( "html", exist_ok=True ) + for j in range( len( gt2.c ) ): + for k in range( len( gt2.c ) ): + with open( "./html/" + gt2.c[j][0] + gt2.c[k][0] + ".html", "x" ) as f: + source = gt2.c[j][0] + dest = gt2.c[k][0] + + fpathe, fpathv, cpathe, cpathv = gt2.bestpaths( j, k ) + + fprice = sum( [ gt2.edge_prices[i] for i in fpathe ] ) + ftime = sum( [ gt2.edge_times[i] for i in fpathe ] ) + cprice = sum( [ gt2.edge_prices[i] for i in cpathe ] ) + ctime = sum( [ gt2.edge_times[i] for i in cpathe ] ) + f.write( con.render( c=gt2.c, edge_middel=gt2.edge_middel, fastpath_verts=fpathv, fastpath_edges=fpathe, cheappath_verts=cpathv, cheappath_edges=cpathe, edge_prices=gt2.edge_prices, edge_times=gt2.edge_times, source=source, dest=dest, fprice=fprice, ftime=ftime, cprice=cprice, ctime=ctime ) ) + + with open( "./html/index.html", "x" ) as f: + f.write( index.render( headers=headers ) ) + #f.write( index.render( c=gt2.c, edge_middel=gt2.edge_middel, fastpath_verts=fpathv, fastpath_edges=fpathe, cheappath_verts=cpathv, cheappath_edges=cpathe, lenf=len( fpathe ), lenc=len( cpathe ), edge_prices=gt2.edge_prices, edge_times=gt2.edge_times, source=source, dest=dest, fprice=fprice, ftime=ftime, cprice=cprice, ctime=ctime ) ) diff --git a/gt2.py b/gt2.py @@ -0,0 +1,422 @@ +#!/usr/bin/env python3 +import igraph as ig +import matplotlib.pyplot as plt +import numpy as np +import math +import sys +import time + +# I computed these magic constants for the price and time functions by +# collecting data from playing the game and using linear regression + +def a_price( a, b ): + """ price function for air travel""" + return distance( a, b ) * 4107 + 611 + +def a_time( a, b ): + """ time function for air travel""" + return distance( a, b ) * 11.5 + 1 + +def r_price( a, b ): + """ price function for bus routes""" + return distance( a, b ) * 780 + 115 + +def r_time( a, b ): + """ time function for bus routes""" + return distance( a, b ) * 93 + +def b_price( a, b ): + """ price function for boats""" + return distance( a, b ) * 1364 + 205 + +def b_time( a, b ): + """ price function for boats""" + return distance( a, b ) * 130 + 1 + +def t_price( a, b ): + """ price function for trains""" + return distance( a, b ) * 1762 + 261 + +def t_time( a, b ): + """ time function for trains""" + return distance( a, b ) * 54 + +def distance( i, j ): + lon1 = c[i][1] + lat1 = c[i][2] + lon2 = c[j][1] + lat2 = c[j][2] + # Convert degrees to radians + coordinates = lat1, lon1, lat2, lon2 + phi1, lambda1, phi2, lambda2 = [ + math.radians( c ) for c in coordinates + ] + # Apply the haversine formula + d = math.acos(math.cos(phi2-phi1) - math.cos(phi1) * math.cos(phi2) * + (1-math.cos(lambda2-lambda1))) + return d + +def print_connections( bys ): + """ pretty prints the connections of given city""" + byi = d[bys] + + for tr in s: + forb = tr.neighbors( byi ) + print("-- {} --".format( tr.title ) ) + for f in forb: + print( " ", c[f][0], ) +def ec( l ): + return [ c[b][0] for b in l ] + +def plot_path(): + """ Plots a nice matplotlib graph of the travel network. + if invoked after calling best_paths() the cheapest and fastest routes are emphasized + """ + fig, ax = plt.subplots() + ig.plot( + transport, + target=ax, + vertex_color='bisque', + vertex_label=[ city[0] for city in c ], + #layout="", + #edge_width=transport.es['width'], + edge_color=edge_colors, + #edge_label=edge_prices, + #edge_color='#666', + edge_align_label=True, + edge_background='white' + ) + plt.show() + +def bestpaths( source, destination ): + src = source + dest = destination + fastpath_edges, = transport.get_shortest_paths(src, to=dest, weights=edge_times, output="epath") + fastpath_verts, = transport.get_shortest_paths(src, to=dest, weights=edge_times, output="vpath") + cheappath_edges, = transport.get_shortest_paths(src, to=dest, weights=edge_prices, output="epath") + cheappath_verts, = transport.get_shortest_paths(src, to=dest, weights=edge_prices, output="vpath") + + return fastpath_edges, fastpath_verts, cheappath_edges, cheappath_verts + + + +# longitude and latitude data from cityinfo in the game files + +c = [ #cities + # [ by, long, lat ] + [ "Alaska", -150, 61 ], + [ "Amazonas", -60, -3 ], + [ "Amsterdam", 6, 52 ], + [ "Athens", 23, 38 ], + [ "Bangkok", 101, 10 ], + [ "Berlin", 13, 52.5 ], + [ "Boston", -72, 42 ], + [ "Budapest", 16, 47.5 ], + [ "Costa Rica", -84, 8 ], + [ "El Mundo Maya", -89, 20 ], + [ "Galapagos", -90, 0 ], + [ "Havana", -82, 23 ], + [ "Hawaii", -155, 20 ], + [ "Irkutsk", 102, 53 ], + [ "Ireland", -8, 53 ] , + [ "Iceland", -18, 65 ], + [ "Lhasa", 91, 30 ], + [ "London", 0, 53 ], + [ "Maldives", 73, 4 ], + [ "Manila", 124, 15 ], + [ "Montreal", -73.5, 45.5], + [ "New Delhi", 87.5, 28 ], + [ "New Zealand", 177, -41 ], + [ "Paris", 2.5, 49 ], + [ "Sahara", 2, 22 ], + [ "Samarkand", 67, 39.5 ], + [ "San Francisco", -122.5, 38 ], + [ "Shanghai", 123, 28 ], + [ "St. Petersburg", 30.5, 62 ], + [ "Sydney", 152, -37 ], + [ "Tanzania", 33, -7 ], + [ "The Wild West", -106, 41 ], + [ "Tokyo", 140, 36 ], + [ "Washington", -77, 39 ], + [ "Yemen", 48, 14 ], + [ "Zanzibar", 43, -9 ], + [ "Mount Everest", 87.5, 28 ], + [ "Thimphu", 91, 26 ], + [ "Copenhagen", 12.5, 55.5 ] +] + +d = dict( [ ( c[i][0], i ) for i in range( len( c ) ) ] ) + +# adjacencies from the travel planner +# no, these following adjacency matrices were no particular fun to enter + +a = np.array([ #adjacency matrix for flyforbindelser + # | | | | | | | | | | | | | | | | | | | | | | | | | | | | g| | | | | | | | | | + # | | | | | | | | | a| | | | | | | | | | | | | | | | | o| | r| | | t| | | | | t| | + # | | | | | | | | | y| | | | | | | | | | | | | | | | | c| | u| | | s| | | | | s| | + # | | | | | | | | | a| | | | | | | | | | | | | d| | | | s| | b| | | e| | | | | e| | + # | | | | | | | | a| M| | | | | | | | | | | | | n| | | | i| | s| | | W| | n| | | r| | n + # | | m| | | | | | c| | s| | | | | | | | | | | i| a| | | d| c| | r| | | | | o| | | e| | e + # | s| a| | | | | t| i| o| o| | | | | | | | s| | l| h| l| | | n| n| i| e| | a| d| | t| | r| v| | g + # | a| d| | k| | | s| R| d| g| | | k| d| d| | | e| | a| l| a| | | a| a| a| t| | i| l| | g| | a| E| u| a + # a| n| r| s| o| n| n| e| | n| a| a| i| s| n| n| | n| v| a| e| e| e| | a| k| r| h| e| y| n| i| | n| | b| | h| h + # k| o| e| n| k| i| o| p| a| u| p| n| i| t| a| a| a| o| i| l| r| D| Z| s| r| r| F| g| P| e| a| W| o| i| n| i| t| p| n + # s| z| t| e| g| l| t| a| t| M| a| a| a| u| l| l| s| d| d| i| t| | | i| a| a| | n| | n| z| | y| h| e| z| n| m| e + # a| a| s| h| n| r| s| d| s| | l| v| w| k| e| e| a| n| l| n| n| w| w| r| h| m| n| a| .| d| n| e| k| s| m| n| u| i| p + # l| m| m| t| a| e| o| u| o| l| a| a| a| r| r| c| h| o| a| a| o| e| e| a|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| | | | | | | | | | | | | | | | | | | | | | | | g| | | | | | | | | | + # | | | | | | | | | a| | | | | | | | | | | | | | | | | o| | r| | | t| | | | | t| | + # | | | | | | | | | y| | | | | | | | | | | | | | | | | c| | u| | | s| | | | | s| | + # | | | | | | | | | a| | | | | | | | | | | | | d| | | | s| | b| | | e| | | | | e| | + # | | | | | | | | a| M| | | | | | | | | | | | | n| | | | i| | s| | | W| | n| | | r| | n + # | | m| | | | | | c| | s| | | | | | | | | | | i| a| | | d| c| | r| | | | | o| | | e| | e + # | s| a| | | | | t| i| o| o| | | | | | | | s| | l| h| l| | | n| n| i| e| | a| d| | t| | r| v| | g + # | a| d| | k| | | s| R| d| g| | | k| d| d| | | e| | a| l| a| | | a| a| a| t| | i| l| | g| | a| E| u| a + # a| n| r| s| o| n| n| e| | n| a| a| i| s| n| n| | n| v| a| e| e| e| | a| k| r| h| e| y| n| i| | n| | b| | h| h + # k| o| e| n| k| i| o| p| a| u| p| n| i| t| a| a| a| o| i| l| r| D| Z| s| r| r| F| g| P| e| a| W| o| i| n| i| t| p| n + # s| z| t| e| g| l| t| a| t| M| a| a| a| u| l| l| s| d| d| i| t| | | i| a| a| | n| | n| z| | y| h| e| z| n| m| e + # a| a| s| h| n| r| s| d| s| | l| v| w| k| e| e| a| n| l| n| n| w| w| r| h| m| n| a| .| d| n| e| k| s| m| n| u| i| p + # l| m| m| t| a| e| o| u| o| l| a| a| a| r| r| c| h| o| a| a| o| e| e| a| a| a| a| h| t| y| a| h| o| a| e| a| o| h| o + # A| A| A| A| B| B| B| B| C| E| G| H| H| I| I| I| L| L| M| M| M| N| N| P| S| S| S| S| S| S| T| T| T| W| Y| Z| M| T| C + [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], # Alaska + [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], # Washington + [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0 ], # Yemen + [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], # Zanzibar + [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], # Mount Everest + [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], # Thimphu + [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]]) # Copenhagen + +t = np.array([ #adjacency matrix for togforbindelser + # | | | | | | | | | | | | | | | | | | | | | | | | | | | | g| | | | | | | | | | + # | | | | | | | | | a| | | | | | | | | | | | | | | | | o| | r| | | t| | | | | t| | + # | | | | | | | | | y| | | | | | | | | | | | | | | | | c| | u| | | s| | | | | s| | + # | | | | | | | | | a| | | | | | | | | | | | | d| | | | s| | b| | | e| | | | | e| | + # | | | | | | | | a| M| | | | | | | | | | | | | n| | | | i| | s| | | W| | n| | | r| | n + # | | m| | | | | | c| | s| | | | | | | | | | | i| a| | | d| c| | r| | | | | o| | | e| | e + # | s| a| | | | | t| i| o| o| | | | | | | | s| | l| h| l| | | n| n| i| e| | a| d| | t| | r| v| | g + # | a| d| | k| | | s| R| d| g| | | k| d| d| | | e| | a| l| a| | | a| a| a| t| | i| l| | g| | a| E| u| a + # a| n| r| s| o| n| n| e| | n| a| a| i| s| n| n| | n| v| a| e| e| e| | a| k| r| h| e| y| n| i| | n| | b| | h| h + # k| o| e| n| k| i| o| p| a| u| p| n| i| t| a| a| a| o| i| l| r| D| Z| s| r| r| F| g| P| e| a| W| o| i| n| i| t| p| n + # s| z| t| e| g| l| t| a| t| M| a| a| a| u| l| l| s| d| d| i| t| | | i| a| a| | n| | n| z| | y| h| e| z| n| m| e + # a| a| s| h| n| r| s| d| s| | l| v| w| k| e| e| a| n| l| n| n| w| w| r| h| m| n| a| .| d| n| e| k| s| m| n| u| i| p + # l| m| m| t| a| e| o| u| o| l| a| a| a| r| r| c| h| o| a| a| o| e| e| a| a| a| a| h| t| y| a| h| o| a| e| a| o| h| o + # A| A| A| A| B| B| B| B| C| E| G| H| H| I| I| I| L| L| M| M| M| N| N| P| S| S| S| S| S| S| T| T| T| W| Y| Z| M| T| C + [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], # Alaska + [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], # Amazonas + [ 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 ], # Amsterdam + [ 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], # Zanzibar + [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], # Mount Everest + [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], # Thimphu + [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]]) # Copenhagen + +fly = ig.Graph.Adjacency( + a + a.T, + mode="undirected" +) + +båd = ig.Graph.Adjacency( + b + b.T, + mode="undirected" +) + +tog = ig.Graph.Adjacency( + t + t.T, + mode="undirected" +) + +bus = ig.Graph() +bus.add_vertices( len( c ) ) +bus.add_edges( + [ + ( d["Alaska"], d["San Francisco"] ), + ( d["San Francisco"], d["Washington"] ), + ( d["Boston"], d["Washington"] ), + ( d["The Wild West"], d["El Mundo Maya"] ), + ( d["Costa Rica"], d["El Mundo Maya"] ), + ( d["Costa Rica"], d["Amazonas"] ), + ( d["Yemen"], d["Budapest"] ), + ( d["St. Petersburg"], d["Budapest"] ), + ( d["St. Petersburg"], d["Irkutsk"] ), + ( d["London"], d["Amsterdam"] ), + ( d["Paris"], d["Amsterdam"] ), + ( d["Paris"], d["Athens"] ), + ( d["Lhasa"], d["Mount Everest"] ), + ( d["Thimphu"], d["Mount Everest"] ), + ( d["Thimphu"], d["Bangkok"] ), + ( d["Tanzania"], d["Sahara"] ), + ( d["Samarkand"], d["Sahara"] ), + ( d["Samarkand"], d["New Delhi"] ) + ] +) + +s = [ fly, tog, båd, bus ] +titles = [ "flyforbindelser", "togforbindelser", "bådforbindelser", "busforbindelser" ] +colors = [ "darkgreen", "darkorange", "darkblue", "darkred" ] +midler = [ "fly", "tog", "båd", "bus" ] +pf = [ a_price, t_price, b_price, r_price ] # price functions +tf = [ a_time, t_time, b_time, r_time ] # time functions +pl = [] # prices lists +tl = [] # time lists +edges = [] + +for i in range( 4 ): + s[i].title = titles[i] + s[i].p = pf[i] + s[i].t = tf[i] + edges.append( s[i].get_edgelist() ) + pl.append( [ round( s[i].p( j, k ), -1 ) for j, k in edges[i] ] ) + tl.append( [ round( s[i].t( j, k ) ) for j, k in edges[i] ] ) + s[i].es["color"] = colors[i] + s[i].es["middel"] = midler[i] + +transport = ig.Graph( len( c ) ) + +edge_prices = [ p for ps in pl for p in ps ] +edge_times = [ t for ts in tl for t in ts ] +edge_colors = fly.es["color"] + tog.es["color"] + båd.es["color"] + bus.es["color"] +edge_middel = fly.es["middel"] + tog.es["middel"] + båd.es["middel"] + bus.es["middel"] + +for i in range( 4 ): + transport.add_edges( s[i].get_edgelist() ) + +transport.es["width"] = 0.5 + +#for i in epath: +# edge_colors[i] = "deeppink" + +if __name__ == "__main__": + if len( sys.argv ) == 3: + source = d[sys.argv[1]] + dest = d[sys.argv[2]] + else: + source = 0 + dest = 0 + + fastpath_edges, fastpath_verts, cheappath_edges, cheappath_verts = bestpaths( source, dest ) + + transport.es[ fastpath_edges ]["width"] = 2 + transport.es[ cheappath_edges ]["width"] = 4 + + print( "----------- fastpath -----------" ) + print( "price, time" ) + print( sum( [ edge_prices[i] for i in fastpath_edges] ), "DKK", sum( [ edge_times[i] for i in fastpath_edges] ), "H" ) + print( c[ fastpath_verts[0] ][0] ) + for i in range( len( fastpath_edges ) ): + print( " ", edge_middel[ fastpath_edges[i] ], edge_prices[ fastpath_edges[i] ], "DKK", edge_times[ fastpath_edges[i] ], "H" ) + print( c[ fastpath_verts[i+1] ][0] ) + + print( "----------- cheappath ----------" ) + print( "price, time" ) + print( sum( [ edge_prices[i] for i in cheappath_edges] ), "DKK", sum( [ edge_times[i] for i in cheappath_edges] ), "H" ) + print( c[ cheappath_verts[0] ][0] ) + for i in range( len( cheappath_edges ) ): + print( " ", edge_middel[ cheappath_edges[i] ], edge_prices[ cheappath_edges[i] ], "DKK", edge_times[ cheappath_edges[i] ], "H" ) + print( c[ cheappath_verts[i+1] ][0] ) + + plot_path() diff --git a/price_functions.ggb b/price_functions.ggb Binary files differ. diff --git a/templates/base.html b/templates/base.html @@ -0,0 +1,15 @@ +{# base.html #} + <!DOCTYPE html> + <html lang="en"> + <head> + <title>{% block title %}{% endblock %}</title> + <meta charset="UTF-8"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + <link rel="stylesheet" href="stylesheet.css"> + <link rel="icon" type="image/png" href="data:image/png;base64,"> + </head> + <body> + {% block content %} + {% endblock %} + </body> + </html> diff --git a/templates/con.html b/templates/con.html @@ -0,0 +1,30 @@ +{% extends "base.html" %} +{% block content %} + <h1>{{ source }} &rarr; {{ dest }}</h1> + + <h2>min(time)</h2> + <h3>{{ fprice | int }}DKK, {{ ftime }}H</h3> + <ol> + <li>{{ c[ fastpath_verts[0] ][0] }}</li> + {% for i in fastpath_edges %} + <ul> + <li>&darr;{{ edge_middel[i] }}, {{ edge_prices[i] | int }}DKK, {{ edge_times[i] }}H</p> + </ul> + <li>{{ c[ fastpath_verts[ loop.index0 + 1 ] ][0] }}</li> + {% endfor %} + </ol> + <h2>min(price)</h2> + <h3>{{ cprice | int }}DKK, {{ ctime }}H</h3> + <ol> + <li>{{ c[ cheappath_verts[0] ][0] }}</li> + {% for i in cheappath_edges %} + <ul> + <li>&darr;{{ edge_middel[i] }}, {{ edge_prices[i] | int }}DKK, {{ edge_times[i] }}H</p> + </ul> + <li>{{ c[ cheappath_verts[ loop.index0 + 1 ] ][0] }}</li> + {% endfor %} + </ol> +{% endblock %} +{% block title %} +{{ source }} &rarr; {{ dest }} +{% endblock %} diff --git a/templates/index.html b/templates/index.html @@ -0,0 +1,20 @@ +{% extends "base.html" %} +{% block content %} + <table> + <tr> + <th></th> + {% for th in headers %} + <th>{{ th | replace( " ", "&nbsp;" ) | safe }}</th> + {% endfor %} + </tr> + {% for i in headers %} + <tr> + <th> {{ i | replace( " ", "&nbsp;" ) | safe }} </th> + {% for j in headers %} + <td> <a href="{{ j + i }}.html">X</a> </td> + {% endfor %} + </tr> + {% endfor %} + </table> +{% endblock %} +