The current version of the game is playable here.
The purpose of the game is to learn TriMet bus and MAX routes. It's easy to get somewhere by transit. One can look up transit directions on Trimet.org or Google Maps. This does not help to learn transit in a city. In fact, city dwellers generally stay in localized areas so they are not exposed to all routes. This game helps all users engage with TriMet's service and learn by guessing the correct itinerary. Play every day and you'll be surprised at what you learn!
The game has several elements described below:
- route paths - routes are built from the gtfs shapes.txt file.
- itineraries - itineraries and "leg" geometries are provided by TriMet's trip planner.
- origin | destination - origin and destination points are randomly generated points within 0.5 miles of a TriMet route shape.
- basemap - Stanem Design basemap is used to remove a lot of detail and focus mainly on the origin and destination relative location.
Semi-regular (when GTFS changes):
- Download the latest gtfs.zip file from TriMet
from zipfile import ZipFile
from urllib.request import urlopen
resp = urlopen("https://developer.trimet.org/schedule/gtfs.zip")
myzip = ZipFile(BytesIO(resp.read()))
myzip.extractall('gtfs/')
- Create route list for game dropdown from routes.txt
- Create route lines from shapes.txt, buffer the lines, union all lines together and save as geojson
gtfs_shapes = pd.read_csv('gtfs/shapes.txt')
gtfs_shapes['vertex_point'] = [Point(x, y)
for x, y in zip(gtfs_shapes['shape_pt_lon'].to_numpy()
,gtfs_shapes['shape_pt_lat'].to_numpy())]
gtfs_shape_lines = (gtfs_shapes.groupby('shape_id')[['vertex_point']]
.agg(lambda x: LineString(list(x)))
.reset_index()
.rename(columns={'vertex_point':'route_line'}))
gtfs_shape_lines_gdf = gpd.GeoDataFrame(gtfs_shape_lines, crs="EPSG:4326", geometry='route_line')
3x Daily:
- Generate a random origin and destination point within the route shape from step #3 above.
- Submit the origin and destination points to the TriMet trip planner API
- Verify that there is a viable itinerary
- Return all possible itineraries to populate the game
- Submit the origin and destination points to Mapbox’s API and return traffic driving time to the game
The game starts with a red circle for the origin and destination point. The goal of the game is to select the route(s) to get from the origin point to the destination point via a searchable dropdown.
For every correct guess, the route will show up on the map in a bright color and the corresponding route circle within the itinerary bubble will turn blue.
For every incorrect guess, the corresponding route will show up in a dark red line on the map and the bad guess tracker count will increment up by one.
When all routes within an itinerary bubble are guessed correctly, the whole itinerary bubble turns blue and says “You WIN!” with the full travel time of the itinerary.