taking students out for a ride: using a board game to ... · taking students out for a ride: using...

5
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 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 ma- nipulate graph data. The programming assignment tied to the game forces the students to come to grips with the algo- rithmic aspects of graph theory, including the proper choice of data structures and the implementation of graph algo- rithms. 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 differ- ent courses, including data structures, networks, algorithms, and formal languages. However, the topic of graph theory usually falls under the auspices of a mathematics depart- ment. In this situation, graph theory is formally introduced using strict mathematical definitions and notations, accom- panied with problem solving via proofs. Typical resources for introducing graph theory to students include texts [6, 7, 16], software [14, 5, 10], and countless 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. sites across the internet. In a class devoted towards Object- Oriented 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 com- puter 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 intro- duce 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 intro- duction to graph theory in an sophomore-level class called “Object-Oriented Design and Programming.” Its gameplay elements require the understanding of both basic graph the- ory topics such as vertices, edges and paths, and algorith- mic concepts such as finding the longest path in a graph. After discussing how to play the game during class, the cor- responding 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 sec- tion 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. 2. TICKET TO RIDE: THE GAME The gameboard itself is a graphical model of nineteenth century North America, complete with vertices represent- ing 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- 367

Upload: phamdien

Post on 18-Jul-2018

215 views

Category:

Documents


0 download

TRANSCRIPT

Taking Students Out for a Ride: Using a Board Game toTeach Graph Theory

Darren LimSiena College

515 Loudon RoadLoudonville, New York

[email protected]

ABSTRACTThis paper describes the use of a board game as a device forintroducing graph theory to computer science students. Byexperiencing a hands-on demonstration of graphs, studentscan better understand the basic principles of graph theoryand can better design algorithms and programs which ma-nipulate graph data. The programming assignment tied tothe game forces the students to come to grips with the algo-rithmic aspects of graph theory, including the proper choiceof data structures and the implementation of graph algo-rithms.

Categories and Subject DescriptorsK.3.2 [Computer and Information Science Education]:Computer Science Education—Curriculum; G.2.2 [Discrete

Mathematics]: Graph Theory

General TermsNone

KeywordsComputer Science Education, Graph Theory, Games

1. INTRODUCTIONGraphs and graph theory are fundamental aspects of a

computer science curriculum. Graphs appear in many differ-ent courses, including data structures, networks, algorithms,and formal languages. However, the topic of graph theoryusually falls under the auspices of a mathematics depart-ment. In this situation, graph theory is formally introducedusing strict mathematical definitions and notations, accom-panied with problem solving via proofs.

Typical resources for introducing graph theory to studentsinclude texts [6, 7, 16], software [14, 5, 10], and countless

Permission to make digital or hard copies of all or part of this work forpersonal or classroom use is granted without fee provided that copies arenot made or distributed for profit or commercial advantage and that copiesbear this notice and the full citation on the first page. To copy otherwise, torepublish, to post on servers or to redistribute to lists, requires prior specificpermission and/or a fee.SIGCSE’07, March 7–10, 2007, Covington, Kentucky, USA.Copyright 2007 ACM 1-59593-361-1/07/0003 ...$5.00.

sites across the internet. In a class devoted towards Object-Oriented Design and Advanced Java programming, the topicof graph theory was presented in a novel fashion: by usinga board game. Games have been source material for com-puter sciences teachers for decades. Monopoly [15] and evenChutes and Ladders [1] have been examples for computersimulation and modeling. C-jump [2] can be used to intro-duce students to fundamental constructs of programmingsuch as conditionals, increments, loops, and jumps. Chess[12, 8], Checkers [13] and Connect Four [4] have all been usedin discussions regarding artificial intelligence. The dice gamePig has been used to illustrate concepts in a CS1 course [11].Even video games have been used as class material in CScurriculums [9, 17].

The board game Ticket to Ride [3] was used as an intro-duction to graph theory in an sophomore-level class called“Object-Oriented Design and Programming.” Its gameplayelements require the understanding of both basic graph the-ory topics such as vertices, edges and paths, and algorith-mic concepts such as finding the longest path in a graph.After discussing how to play the game during class, the cor-responding homework assignment required the students toimplement a graph data structure and a searching methodfor their structures.

The organization of this paper is as follows. The next sec-tion outlines the basic rules and gameplay of Ticket to Ride.The following sections discuss how the game can be usedas a tool to present concepts of graph theory to students.Finally, a concluding section will discuss future use of thegame in larger scale projects.

2. TICKET TO RIDE: THE GAMEThe gameboard itself is a graphical model of nineteenth

century North America, complete with vertices represent-ing cities and edges representing “train routes” from onecity to another. The board is shown in Figure 1. Theobject of Ticket to Ride is to accumulate the most pointsamong all players. Each player is awarded points during thegame when he or she claims a unclaimed route on the board.These routes are claimed by discarding colored cards froma hand that match, in color and quantity, a particular routeon the board. That player marks the route as claimed bythemselves by placing train tokens at the route’s locationon the board. At the end of the game, points are tallied upfor each route claimed. At this time, additional points areawarded (or deducted) based on special Destination Tickets,which are acquired throughout the game. After these spe-

367

Figure 1: The Ticket to Ride Board Game.

cial award points are distributed, the player with the mostpoints is declared the winner.

2.1 A Player’s TurnDuring 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 cardsBefore a player can claim a route between cities, he or she

must first build up a hand of train cards. In the game, thereare eight colored train cards, each of which depicts a differ-ent type of train car (Box, Caboose, Coal, Freight, Hopper,Passenger, Reefer, and Tanker). A special locomotive actsas a wildcard. They are all shown in Figure 2. Each playerstarts the game with four random train car cards in theirhand. At each turn, five cards are displayed face up forchoosing from the deck. The player can either choose a faceup card, or choose a card from the top of the deck. If theplayer does not choose a face up wildcard (a card which canrepresent any color), the player may choose a second card:either a non-wildcard face up card or a card from the topof 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 fiveface up cards are discarded, and five new face up cards aretaken from the top of the deck.

2.1.2 Claiming routesOne individual route can be claimed during a player’s

turn. Each route has a distinct color and length. To claiman orange route of length three, for example, a player mustdiscard exactly three orange (or wildcard) cards from hisor her hand. Players designate a claimed route by placingtrain tokens of their color on the board. Once a route isclaimed by any player, it can not be reclaimed by any otherplayer for the remainder of the game. In Figure 4, the green

Figure 2: Train Cards. These are drawn and sub-

sequently 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 whichcorrespond to the colors of the train cards. A grey coloredroute, can be claimed by any set of colored cards (or wild-cards). For example, the grey route between Houston andNew Orleans of length two could be claimed by discardingtwo orange train cards, two green train cards, one green andone wildcard, etc.

2.1.3 Drawing Destination TicketsAt the beginning of the game, each player draws three des-

tination tickets and keeps at least two of them. An exampleis shown in Figure 3.

A Destination Ticket is a card with two highlighted citiesand a point value. The point value represents the amount ofpoints the player holding the challenge card would receiveat the end of the game if that player controls a path ofroutes between both cities on the card. During regular play,

368

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 shemay then discard up to two of those cards drawn.

2.2 Determining the winnerEvery player starts with forty-five train tokens, with which

to claim train routes. Each player gets one final turn when-ever any one player has zero, one or two train tokens avail-able to play. At the end of the game, players are rewardedpoints for each route claimed, according to Table 1.

Route Length Points Awarded1 12 23 44 65 106 15

Table 1: Route Point Values

Players are also awarded points for each successfully metdestination ticket that they possess. A Destination Ticketis met only if a path exists between both cities designatedon the ticket. A player can connect cities with a path usingonly edges claimed by himself or herself. If such a path doesnot exist, the points are deducted from the player for thatDestination Ticket. Finally, ten bonus points are awardedfor the player with the longest continuous path of capturedroutes.

3. TICKET TO RIDE: CONCEPTS IN GRAPHTHEORY

By showing students the gameboard graph (for the re-mainder of the paper, the graph of the full gameboard willbe referred to as the full graph), many simple concepts canbe easily discussed.

3.1 Properties of VerticesEach vertex of the full graph represents one of thirty-

six different cities from nineteenth century North America.Students can learn what exactly is meant by vertices andedges, rather than digesting the classic, formal definition ofa graph (a pair G = (V, E)...). They can see a real exampleof information that is more easily described and presentedusing graphs. By using train tokens, the concepts of adja-

cency incidence, and degree can be quickly shown. In Figure

4, students can see that Helena is incident to seven routes,while Salt Lake City is incident to merely five. Thus, thedegree of these two vertices are seven and five, respectively.

Figure 4: Claimed Routes in the Northwest

3.2 Properties of EdgesAfter examining the board, students can easily see that

the seventy-eight edges are not all the same; each edge hasone of nine colors and a length between one and six. Thishas two implications. First, students will have to properlymodel their edges as a class entity, instead of a primitive int

datatype. This gives the students another chance to practicetheir Java class designing skills.

The second implication is that the two edge properties al-low the instructor to introduce several topics of algorithmicgraph theory. Because each edge has a specific color, thetopic of edge coloring could be discussed. Since each edgehas a specific length, that value can be used as a weightfor discussions on minimum spanning tree algorithms, andshortest path algorithms.

3.3 Simple Graphs and MultigraphsOne of the first things that students notice about the

routes on the gameboard is that some are doubled betweentwo adjacent cities. Several vertices, such as Seattle andPortland in Figure 4 are connected by two edges instead ofone. Most of the board is modeled as a simple graph; how-ever, the presence of multiple edges illustrates that the fullgraph is an example of a multigraph. This fact will have im-mediate implications on students’ choices of data structures.

3.4 Subgraphs and ComponentsStudents quickly realize that the board has more edges

than any one player could claim. Thus, the set of ver-tices(cities) and edges(routes) covered by a player’s traintoken set is a smaller graph, namely a player’s Edge-Induced

subgraph. The subgraph clearly need not include the entireset of vertices nor edges. Subgraphs need not even be fullyconnected; two separate subgraphs can exist on the board.This allows the instructor to describe separate components

of graphs.

3.5 Paths and CyclesDetermining whether a Destination Ticket has been met is

done by finding a path between two cities (vertices). Paths

369

Figure 5: A Cycle in the South

in the graph can be easily described using the board andtrain tokens. In Figure 4, a path of claimed routes existsbetween Portland and Denver (through Salt Lake City). Aninstructor can use tokens to illustrate the subtle differencesbetween a path, a trail, and a walk.

The concept of cycles can also be illustrated by claiming aroute (or a path of edges) to two cities already connected bythe player such as in Figure 5. Students soon recognize that,from a strategic standpoint, creating cycles in their collec-tion of claimed train routes does not increase their coverageof cities and therefore does not help them meet their Desti-nation Tickets.

3.6 Trees and Spanning TreesSince a player doesn’t benefit from creating cycles in his

or her subgraph of claimed routes (except in the case whereclaiming a route blocks other players from joining or extend-ing paths), the ideal selection of edges would form a forest

or tree, depending on the number of components. A near-perfect strategy for a player is to create a spanning tree ofthe graph. By definition, a spanning tree of the full graphwould guarantee that any Destination Ticket would be ful-filled.

Players do not have enough train tokens to claim a span-ning tree of the full graph. Thus, to fulfill the Destinationcards in their hands, the best strategy is to capture a mini-

mal spanning tree or forest of a subset of vertices (includingthose on their Destination Tickets) of the full graph.

4. TICKET TO RIDE: CONCEPTS IN COM-PUTER SCIENCE

The programming assignment for the class was to computethe 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 (twocities and a value); and edge.txt, which contained a list ofroutes claim. Sample input is shown in Table 2.

Students had two weeks to write a program which wouldcalculate a player’s final score (the example from Table 2 has

Input Files

card.txt 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

Table 2: Route Point Values

a final score of 94) using the Java programming language.As a guide, a sample jarfile application and sample inputdata were provided.

To accomplish this (besides the usual File I/O processingand string parsing), the students need to understand severalconcepts from algorithmic graph theory.

4.1 Graph Data RepresentationImplementing graphs is a classic topic of a Data Struc-

tures course. Typically, students need to understand thetwo methods for representing graph data: adjacency matri-

ces and adjacency lists. The board of Ticket to Ride makestheir decision an interesting one, since the full adjacencymatrix is quite sparse. Although not required for the assign-ment, students implementing the full graph must also thinkabout how to properly handle multiple edges between nodes.In some cases, these multiple edges aren’t alike; sometimesthese edges have different colors.

After describing both data structures in class, most stu-dents initially implemented their graphs using adjacencymatrices. This is not surprising, since two-dimensional ar-rays are a more familiar data structure for them. Studentsquickly realized that there is a trade-off in their choice ofdata structure. Adjacency matrices allow for easier calcula-tions of edge scores, while adjacency lists allow for simplerimplementations of Destination Ticket scoring.

4.2 Depth-First, or Breadth-First, SearchThe scoring aspect of the individual edges is a simple

lookup in the full graph data structure. The DestinationTickets require a more sophisticated algorithm for determin-ing whether the player should have points awarded or de-ducted for each Destination Ticket in his or her hand. Thisis best implemented by using a Depth-First Search (DFS)algorithm.

In class, the DFS algorithm was shown as a method fordetermining the number of components in a graph. It wasshown in a non-recursive form, such that an adjustment inthe “next vertex to visit” array would drastically change thevisiting order. Treating the array as a stack would producea Depth-First Search; treating the array as a queue wouldproduce a Breadth-First Search.

370

4.3 Path AlgorithmsGiven 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 aspossible. This information is obtained through Dijkstra’salgorithm. Implementing Dijkstra’s algorithm is a classictopic for algorithms classes, since a careful choice of datastructures (adjacency lists and binary heaps) can affect thebig-O complexity.

A final ten point bonus is awarded to the player with thelongest path on the board. Finding the longest path in anarbitrary graph is NP-Complete. Explaining to studentswhy finding the longest path in the general case is such adifficult problem allows the instructor to talk about severalother difficult graph problems, such as Hamiltonian Cycle,Vertex Coloring, Independent Set, and Graph Isomorphism.

5. CONCLUSION AND FUTURE WORKUsing Ticket to Ride can be an excellent way to intro-

duce graph theory to computer science students. It allowsthe instructor to visually demonstrate both simple and com-plex concepts. The game itself offers many different ideasfor problems and programming assignments. Although ahands-on approach is certainly no replacement for proofsand mathematical formalism, using this boardgame can sup-plement the graph theory educational experience.

In the future, the assignment can be extended to a half-semester project, where teams would have to maintain player’sclaimed routes and card hands throughout the game. Theirprojects would update scores on each turn and would alsoidentify the player who current has the longest continuouspath. A full-semester project for Ticket to Ride would bethe creation of a computerized player, replete with in-gamepositional analysis, route-claiming decision making based onthe computer’s hand, and tactical heuristics with regards topreventing 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/.

[4] V. Allis. A knowledge-based approach of connect-four:The game is solved: White wins. Master’s thesis, VrijeUniversiteit, 1988.

[5] J. Berry, N. Dean, M. Goldberg, G. Shannon, andS. Skiena. Link: A system for graph computation.Software Practice and Experience, 30(11):1285–1302,2000.

[6] G. Chartrand. Introductory Graph Theory. DoverPublications, 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. MorganKaufmann, 1999.

[9] B. Ladd. The curse of monkey island: Holding theattention 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. CambridgeUniversity 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, June2006.

[12] A. Newell, J. C. Shaw, and H. A. Simon.Chess-playing programs and the problem ofcomplexity. 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. AddisonWesley 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. Digitalgaming as a vehicle for learning. In Proceedings of the

37th SIGCSE technical symposium on Computer

science education, pages 394–395, 2006.

371