Taking Students Out for a Ride: Using a Board Game to Teach Graph Theory Darren Lim Siena College 515 Loudon Road Loudonville, New York [email protected] ABSTRACT sites across the internet. In a class devoted towards ObjectOriented Design and Advanced Java programming, the topic of graph theory was presented in a novel fashion: by using a board game. Games have been source material for computer sciences teachers for decades. Monopoly [15] and even Chutes and Ladders [1] have been examples for computer simulation and modeling. C-jump [2] can be used to introduce students to fundamental constructs of programming such as conditionals, increments, loops, and jumps. Chess [12, 8], Checkers [13] and Connect Four [4] have all been used in discussions regarding artificial intelligence. The dice game Pig has been used to illustrate concepts in a CS1 course [11]. Even video games have been used as class material in CS curriculums [9, 17]. The board game Ticket to Ride [3] was used as an introduction to graph theory in an sophomore-level class called “Object-Oriented Design and Programming.” Its gameplay elements require the understanding of both basic graph theory topics such as vertices, edges and paths, and algorithmic concepts such as finding the longest path in a graph. After discussing how to play the game during class, the corresponding homework assignment required the students to implement a graph data structure and a searching method for their structures. The organization of this paper is as follows. The next section outlines the basic rules and gameplay of Ticket to Ride. The following sections discuss how the game can be used as a tool to present concepts of graph theory to students. Finally, a concluding section will discuss future use of the game in larger scale projects. This paper describes the use of a board game as a device for introducing graph theory to computer science students. By experiencing a hands-on demonstration of graphs, students can better understand the basic principles of graph theory and can better design algorithms and programs which manipulate graph data. The programming assignment tied to the game forces the students to come to grips with the algorithmic aspects of graph theory, including the proper choice of data structures and the implementation of graph algorithms. Categories and Subject Descriptors K.3.2 [Computer and Information Science Education]: Computer Science Education—Curriculum; G.2.2 [Discrete Mathematics]: Graph Theory General Terms None Keywords Computer Science Education, Graph Theory, Games 1. INTRODUCTION Graphs and graph theory are fundamental aspects of a computer science curriculum. Graphs appear in many different courses, including data structures, networks, algorithms, and formal languages. However, the topic of graph theory usually falls under the auspices of a mathematics department. In this situation, graph theory is formally introduced using strict mathematical definitions and notations, accompanied with problem solving via proofs. Typical resources for introducing graph theory to students include texts [6, 7, 16], software [14, 5, 10], and countless 2. TICKET TO RIDE: THE GAME The gameboard itself is a graphical model of nineteenth century North America, complete with vertices representing cities and edges representing “train routes” from one city to another. The board is shown in Figure 1. The object of Ticket to Ride is to accumulate the most points among all players. Each player is awarded points during the game when he or she claims a unclaimed route on the board. These routes are claimed by discarding colored cards from a hand that match, in color and quantity, a particular route on the board. That player marks the route as claimed by themselves by placing train tokens at the route’s location on the board. At the end of the game, points are tallied up for each route claimed. At this time, additional points are awarded (or deducted) based on special Destination Tickets, which are acquired throughout the game. After these spe- Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. To copy otherwise, to republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. SIGCSE’07, March 7–10, 2007, Covington, Kentucky, USA. Copyright 2007 ACM 1-59593-361-1/07/0003 ...$5.00. 367 Figure 1: The Ticket to Ride Board Game. cial award points are distributed, the player with the most points is declared the winner. 2.1 A Player’s Turn During each player’s turn, he or she may choose to do one of the following three maneuvers: • Draw train car card(s) • Claim a route • Draw Destination Tickets 2.1.1 Drawing train car cards Before a player can claim a route between cities, he or she must first build up a hand of train cards. In the game, there are eight colored train cards, each of which depicts a different type of train car (Box, Caboose, Coal, Freight, Hopper, Passenger, Reefer, and Tanker). A special locomotive acts as a wildcard. They are all shown in Figure 2. Each player starts the game with four random train car cards in their hand. At each turn, five cards are displayed face up for choosing from the deck. The player can either choose a face up card, or choose a card from the top of the deck. If the player does not choose a face up wildcard (a card which can represent any color), the player may choose a second card: either a non-wildcard face up card or a card from the top of the train card deck. As a player chooses a face up card, a replacement is put in its place from the top of the deck. If at any time, three locomotive cards are face up, the five face up cards are discarded, and five new face up cards are taken from the top of the deck. 2.1.2 Figure 2: Train Cards. These are drawn and subsequently played from a player’s hand in order to claim a route. player has claimed three routes: Portland ⇔ Salt Lake City, Helena ⇔ Salt Lake City, and Salt Lake City ⇔ Denver. A route has one of nine distinct colors, eight of which correspond to the colors of the train cards. A grey colored route, can be claimed by any set of colored cards (or wildcards). For example, the grey route between Houston and New Orleans of length two could be claimed by discarding two orange train cards, two green train cards, one green and one wildcard, etc. 2.1.3 Claiming routes Drawing Destination Tickets At the beginning of the game, each player draws three destination tickets and keeps at least two of them. An example is shown in Figure 3. A Destination Ticket is a card with two highlighted cities and a point value. The point value represents the amount of points the player holding the challenge card would receive at the end of the game if that player controls a path of routes between both cities on the card. During regular play, One individual route can be claimed during a player’s turn. Each route has a distinct color and length. To claim an orange route of length three, for example, a player must discard exactly three orange (or wildcard) cards from his or her hand. Players designate a claimed route by placing train tokens of their color on the board. Once a route is claimed by any player, it can not be reclaimed by any other player for the remainder of the game. In Figure 4, the green 368 4, students can see that Helena is incident to seven routes, while Salt Lake City is incident to merely five. Thus, the degree of these two vertices are seven and five, respectively. Figure 3: A Destination Ticket. Completing a path between Miami and Los Angeles garners twenty points a player may choose to draw three challenge cards; he or she may then discard up to two of those cards drawn. 2.2 Determining the winner Every player starts with forty-five train tokens, with which to claim train routes. Each player gets one final turn whenever any one player has zero, one or two train tokens available to play. At the end of the game, players are rewarded points for each route claimed, according to Table 1. Route Length 1 2 3 4 5 6 Figure 4: Claimed Routes in the Northwest 3.2 Properties of Edges After examining the board, students can easily see that the seventy-eight edges are not all the same; each edge has one of nine colors and a length between one and six. This has two implications. First, students will have to properly model their edges as a class entity, instead of a primitive int datatype. This gives the students another chance to practice their Java class designing skills. The second implication is that the two edge properties allow the instructor to introduce several topics of algorithmic graph theory. Because each edge has a specific color, the topic of edge coloring could be discussed. Since each edge has a specific length, that value can be used as a weight for discussions on minimum spanning tree algorithms, and shortest path algorithms. Points Awarded 1 2 4 6 10 15 Table 1: Route Point Values Players are also awarded points for each successfully met destination ticket that they possess. A Destination Ticket is met only if a path exists between both cities designated on the ticket. A player can connect cities with a path using only edges claimed by himself or herself. If such a path does not exist, the points are deducted from the player for that Destination Ticket. Finally, ten bonus points are awarded for the player with the longest continuous path of captured routes. 3.3 3. TICKET TO RIDE: CONCEPTS IN GRAPH THEORY One of the first things that students notice about the routes on the gameboard is that some are doubled between two adjacent cities. Several vertices, such as Seattle and Portland in Figure 4 are connected by two edges instead of one. Most of the board is modeled as a simple graph; however, the presence of multiple edges illustrates that the full graph is an example of a multigraph. This fact will have immediate implications on students’ choices of data structures. 3.4 By showing students the gameboard graph (for the remainder of the paper, the graph of the full gameboard will be referred to as the full graph), many simple concepts can be easily discussed. Simple Graphs and Multigraphs Subgraphs and Components Students quickly realize that the board has more edges than any one player could claim. Thus, the set of vertices(cities) and edges(routes) covered by a player’s train token set is a smaller graph, namely a player’s Edge-Induced subgraph. The subgraph clearly need not include the entire set of vertices nor edges. Subgraphs need not even be fully connected; two separate subgraphs can exist on the board. This allows the instructor to describe separate components of graphs. 3.1 Properties of Vertices Each vertex of the full graph represents one of thirtysix different cities from nineteenth century North America. Students can learn what exactly is meant by vertices and edges, rather than digesting the classic, formal definition of a graph (a pair G = (V, E)...). They can see a real example of information that is more easily described and presented using graphs. By using train tokens, the concepts of adjacency incidence, and degree can be quickly shown. In Figure 3.5 Paths and Cycles Determining whether a Destination Ticket has been met is done by finding a path between two cities (vertices). Paths 369 card.txt Input Files edge.txt Sault St. Marie : Nashville : 8 Little Rock : Oklahoma City Sault St. Marie : Oklahoma City : 9 Little Rock : Saint Louis Nashville : Saint Louis Oklahoma City : Kansas City Omaha : Kansas City Omaha : Duluth Winnipeg : Duluth Winnipeg : Helena Sault St. Marie : Winnipeg Sault St. Marie : Duluth Sault St. Marie : Toronto Sault St. Marie : Montreal Toronto : Montreal Toronto : Pittsburgh Toronto : Duluth Figure 5: A Cycle in the South Table 2: Route Point Values in the graph can be easily described using the board and train tokens. In Figure 4, a path of claimed routes exists between Portland and Denver (through Salt Lake City). An instructor can use tokens to illustrate the subtle differences between a path, a trail, and a walk. The concept of cycles can also be illustrated by claiming a route (or a path of edges) to two cities already connected by the player such as in Figure 5. Students soon recognize that, from a strategic standpoint, creating cycles in their collection of claimed train routes does not increase their coverage of cities and therefore does not help them meet their Destination Tickets. a final score of 94) using the Java programming language. As a guide, a sample jarfile application and sample input data were provided. To accomplish this (besides the usual File I/O processing and string parsing), the students need to understand several concepts from algorithmic graph theory. 4.1 Graph Data Representation Implementing graphs is a classic topic of a Data Structures course. Typically, students need to understand the two methods for representing graph data: adjacency matrices and adjacency lists. The board of Ticket to Ride makes their decision an interesting one, since the full adjacency matrix is quite sparse. Although not required for the assignment, students implementing the full graph must also think about how to properly handle multiple edges between nodes. In some cases, these multiple edges aren’t alike; sometimes these edges have different colors. After describing both data structures in class, most students initially implemented their graphs using adjacency matrices. This is not surprising, since two-dimensional arrays are a more familiar data structure for them. Students quickly realized that there is a trade-off in their choice of data structure. Adjacency matrices allow for easier calculations of edge scores, while adjacency lists allow for simpler implementations of Destination Ticket scoring. 3.6 Trees and Spanning Trees Since a player doesn’t benefit from creating cycles in his or her subgraph of claimed routes (except in the case where claiming a route blocks other players from joining or extending paths), the ideal selection of edges would form a forest or tree, depending on the number of components. A nearperfect strategy for a player is to create a spanning tree of the graph. By definition, a spanning tree of the full graph would guarantee that any Destination Ticket would be fulfilled. Players do not have enough train tokens to claim a spanning tree of the full graph. Thus, to fulfill the Destination cards in their hands, the best strategy is to capture a minimal spanning tree or forest of a subset of vertices (including those on their Destination Tickets) of the full graph. 4.2 4. TICKET TO RIDE: CONCEPTS IN COMPUTER SCIENCE Depth-First, or Breadth-First, Search The scoring aspect of the individual edges is a simple lookup in the full graph data structure. The Destination Tickets require a more sophisticated algorithm for determining whether the player should have points awarded or deducted for each Destination Ticket in his or her hand. This is best implemented by using a Depth-First Search (DFS) algorithm. In class, the DFS algorithm was shown as a method for determining the number of components in a graph. It was shown in a non-recursive form, such that an adjustment in the “next vertex to visit” array would drastically change the visiting order. Treating the array as a stack would produce a Depth-First Search; treating the array as a queue would produce a Breadth-First Search. The programming assignment for the class was to compute the final score of a player, based on the following input. • A list of routes claimed by the player. • A list of Destination Tickets possessed by the player. The input files for their programs were two files: card.txt, which contained the Destination Ticket Information (two cities and a value); and edge.txt, which contained a list of routes claim. Sample input is shown in Table 2. Students had two weeks to write a program which would calculate a player’s final score (the example from Table 2 has 370 4.3 Path Algorithms Given a Destination Ticket, such as the one in Figure 3, a player may want to know the shortest path between cities, in order to make the route-claiming process as efficient as possible. This information is obtained through Dijkstra’s algorithm. Implementing Dijkstra’s algorithm is a classic topic for algorithms classes, since a careful choice of data structures (adjacency lists and binary heaps) can affect the big-O complexity. A final ten point bonus is awarded to the player with the longest path on the board. Finding the longest path in an arbitrary graph is NP-Complete. Explaining to students why finding the longest path in the general case is such a difficult problem allows the instructor to talk about several other difficult graph problems, such as Hamiltonian Cycle, Vertex Coloring, Independent Set, and Graph Isomorphism. 5. CONCLUSION AND FUTURE WORK Using Ticket to Ride can be an excellent way to introduce graph theory to computer science students. It allows the instructor to visually demonstrate both simple and complex concepts. The game itself offers many different ideas for problems and programming assignments. Although a hands-on approach is certainly no replacement for proofs and mathematical formalism, using this boardgame can supplement the graph theory educational experience. In the future, the assignment can be extended to a halfsemester project, where teams would have to maintain player’s claimed routes and card hands throughout the game. Their projects would update scores on each turn and would also identify the player who current has the longest continuous path. A full-semester project for Ticket to Ride would be the creation of a computerized player, replete with in-game positional analysis, route-claiming decision making based on the computer’s hand, and tactical heuristics with regards to preventing other players from reaching their target paths. 6. REFERENCES [1] http://www.namics.nysaes.cornell.edu/news15/ cootie.html. [2] http://c-jump.com/. [3] http://www.ticket2ridegame.com/. 371 [4] V. Allis. A knowledge-based approach of connect-four: The game is solved: White wins. Master’s thesis, Vrije Universiteit, 1988. [5] J. Berry, N. Dean, M. Goldberg, G. Shannon, and S. Skiena. Link: A system for graph computation. Software Practice and Experience, 30(11):1285–1302, 2000. [6] G. Chartrand. Introductory Graph Theory. Dover Publications, 1984. [7] G. Chartrand and L. Lesniak. Graphs and Digraphs, 4th Edition. Chapman and Hall/CRC, 2004. [8] E. Heinz. Scalable Search in Computer Chess. Morgan Kaufmann, 1999. [9] B. Ladd. The curse of monkey island: Holding the attention of students weaned on computer games. J. of Computing Sciences in Colleges, 21(6):162–174, June 2006. [10] K. Mehlhorn and S. Naher. The LEDA Platform of Combinatorial and Geometric Computing. Cambridge University Press, 1999. [11] T. Neller, I. Russell, C. Presser, and Z. Markov. Pedagogical possibilities for the dice game pig. J. of Computing Sciences in Colleges, 21(6):149–161, June 2006. [12] A. Newell, J. C. Shaw, and H. A. Simon. Chess-playing programs and the problem of complexity. In Computers and thought, pages 39–70. MIT Press, Cambridge, MA, USA, 1995. [13] J. Schaeffer, R. Lake, P. Lu, and M. Bryant. Chinook: The world man-machine checkers champion. AI Magazine, 17(1):21–29, 1996. [14] J. Siek, L. Lee, and A. Lumsdaine. The Boost Graph Library: User Guide and Reference Manual. Addison Wesley Professional, 2001. [15] I. Stewart. Mathematical recreations. 274(4):104–105, April 1996. [16] D. West. Introduction to Graph Theory, 3rd Edition. Prentice Hall, 2006. [17] U. Wolz, T. Barnes, I. Parberry, and M. Wick. Digital gaming as a vehicle for learning. In Proceedings of the 37th SIGCSE technical symposium on Computer science education, pages 394–395, 2006.
© Copyright 2026 Paperzz