Demo¶
This page showcases game board analysis functionality provided by the package.
Initialize a map¶
This demo will leverage the standard North America map which is an exact replica of the most popular game distribution. However, all illustrated functionality works with arbirtary maps.
In [1]:
Copied!
from ticket_to_ride.default_components import north_america_map
print(north_america_map)
from ticket_to_ride.default_components import north_america_map
print(north_america_map)
North America map with 36 cities and 100 routes.
Visualize a map¶
With a single method call, we get a graph visualization of the map.
In [2]:
Copied!
north_america_map.visualize()
north_america_map.visualize()
Analyze metrics¶
As easy as you just visualized it, you can access map metrics that reveal insights about it based on graph theory.
Centrality¶
In [3]:
Copied!
north_america_map.calculate_centrality()
north_america_map.calculate_centrality()
Out[3]:
{City(name='Saint Louis'): 0.2146178471388555, City(name='Kansas City'): 0.2053681472589036, City(name='Omaha'): 0.16953181272509005, City(name='Denver'): 0.1668827531012405, City(name='Oklahoma City'): 0.1561904761904762, City(name='Nashville'): 0.15599439775910365, City(name='Helena'): 0.1530492196878751, City(name='Pittsburgh'): 0.14201680672268907, City(name='Little Rock'): 0.1260044017607043, City(name='Salt Lake City'): 0.11671868747498997, City(name='Chicago'): 0.11524209683873549, City(name='Atlanta'): 0.11347338935574233, City(name='Duluth'): 0.11302120848339338, City(name='Dallas'): 0.09133653461384553, City(name='Santa Fe'): 0.07829931972789117, City(name='Raleigh'): 0.07056022408963586, City(name='Sault Ste. Marie'): 0.06509403761504601, City(name='Toronto'): 0.05903361344537814, City(name='Seattle'): 0.05829931972789116, City(name='New York'): 0.05238095238095239, City(name='Phoenix'): 0.04495398159263707, City(name='Calgary'): 0.028815526210484197, City(name='Houston'): 0.02755502200880353, City(name='Los Angeles'): 0.027450980392156862, City(name='Portland'): 0.026798719487795122, City(name='El Paso'): 0.0226890756302521, City(name='New Orleans'): 0.021092436974789915, City(name='Winnipeg'): 0.019943977591036416, City(name='Charleston'): 0.013445378151260505, City(name='Montreal'): 0.012044817927170869, City(name='Washington'): 0.01187675070028011, City(name='Las Vegas'): 0.01064825930372149, City(name='San Francisco'): 0.010084033613445379, City(name='Vancouver'): 0.0036414565826330533, City(name='Miami'): 0.0, City(name='Boston'): 0.0}
Contrast ratio¶
Contrast ratio is a fraction of routes that have color other than neutral.
In [4]:
Copied!
north_america_map.calculate_contrast_ratio()
north_america_map.calculate_contrast_ratio()
Out[4]:
0.56