PyLadiesCon 2025

Ticket To Ride + Python: Coding the ultimate expansion pack with a random route generator
, Main Stream
語言: English

In this presentation, my kid and I will talk about building a random route generator to augment the board game Ticket to Ride. Our code chooses cities at random and computes their shortest distance, which translates to points in the game. We explore playful learning and the concepts of computational thinking to learn and implement an algorithm. It’s been a joy to share my love of coding and we are working to improve our project.


My family loves board games and my 9-year old kid loves beating me. He consistently wins in the game Ticket to Ride. He knows all of the routes in the Europe version so he can block me as soon as I start building routes. In an effort to finally win, I wrote a random route generator in Python. It adds an element of surprise and complexity and we are exploring how we can program together. Together, we are coding the ultimate expansion pack to our favorite board game.

Ticket to Ride is a board game where players connect cities with little plastic trains. Players draw destination cards that they need to complete to score points. The point value is determined by the shortest path. Finding the shortest paths for the whole board was a good opportunity to apply the concepts of computational thinking including decomposition, abstraction, and algorithmic thinking.
- Decomposition: The entire problem of computing all the shortest paths was too much to start with, so we decomposed it into a smaller problem by looking at a portion of the board.
- Abstraction: From there, we abstracted this small map as a graph representation.
- Algorithmic Thinking: Together, we used Dijkstra’s algorithm to compute the shortest distances on the small map and then we applied it to our entire map.

Finally, we implemented it by writing code in a Jupyter notebook. We found that we really enjoyed playing with random routes and we are working to improve our code through iteration. Even with the modifications, my kid still beats me, so I’m just going to have to play better. The best part of all this has been sharing my love of coding in a playful way.

Hi! I’m Fay and I am an organizer for PyLadies Boston. I am passionate about using data for good and I am an advocate for cyclist and pedestrian safety (https://mosey-score.streamlit.app). I mostly code by myself, but I’m excited to contribute to open source.