< Back

Settlers of Catan

Settlers of Catan is a board game focused on resource gathering. Every tile on the game board specifies a type of resource that is generated for any settlement placed at one of the verticies on the edge of the tile. Each tile also gets assigned a number, which is the number that the dice needs to be rolled in order to generate that resource. A game begins by letting each player place two starter settlements on the board. There is a lot of strategy that goes into picking these first locations. Your task for this week to to figure out which settlement locations give significantly more resources than other locations.


Setup

Create a directory assignment13 under assignments in your cs170 directory. All code for the assignment should be stored in this directory.

  cd ~/cs170/assignments
  mkdir assignment13 
  cd assignment13

Details

A game of Settlers of Catan consists of 19 hexagonal resource tiles. There are 3 Brick tiles, 1 Desert tile (which always gets assigned a dice roll of 7), 4 Forest tiles, 3 Ore tiles, 4 Sheep tiles, and 4 Wheat tiles. Each of these tiles are arranged in a hexagonal pattern. This pattern results in overlap between settlement locations: Some settlements locations appear on 3 resource tiles, while others only appear on one or two resource tiles. Consult the image below for more information about the board layout.

The catan_layout.in file specifies the structure of a bipartite graph: A graph with two disjoint sets of verticies. Verticies in one set do not have edges connecting them. The only edges that exist in this graph are between the two sets of verticies. In this program, the two types of verticies are Resources and Settlements. An edge exists between a resource tile and a settlement tile only if that settlement can exist on a resource tile.

You should read the input file specified above in order to generate a graph that resembles the image above. You can use either an adjacency matrix or a linked structure to accomplish this.

Once you have generated the graph as specified above, you should randomly assign resources (using the above distributions), as well as number tiles (There are two of every number in the range \([2-11]\) excluding two, seven, and twelve. There are only one of each of those numbers.).

The game of Settlers of Catan is played with two 6-sided dice. Roll these two dice, and their sum will identify a resource tile that should produce a resource for their settlements. For all of the settlement locations on this tile, you should identify which resource was generated and increment a counter for that resource type.

Run your program for at least 10,000 rolls of the dice. For each resource type, specify which settlement location would generate the most of that resource.


Program Outline

Write down an outline of your program on paper. You should define what classes you need, what the attributes of those classes are, and what methods each class will have. For each attribute, define the datatype being stored within and their purpose. For each method, define their Pre and Post conditions.

This is due Monday, Apr. 13th. All of what you define here can (and probably will) change by the time your final program is written. Consider this an "rough draft" for your program. This will help you get started thinking about the problem before Monday. The key things to think about are:



Submission

You are required to submit a tar file to http://inquire.roanoke.edu/. On inquire, there is a link for Assignment 13. You can create a tar file by issuing the following commands:

cd ~/cs170/assignments
tar czvf assignment13.tgz assignment13/

"Hacker" Prompt

  1. Buildings Having one settlement or two settlement locations for a specific resource is good for making sure you get something during every turn. However, it's only good if you can do something with those resources. Finding the locations that allow you to build the most things would be better towards that goal.

    After you have performed all of the rolls, find pairs of settlements that can produce the most of the following structures:

    • Road: Forest + Brick
    • Settlement: Forest + Brick + Wheat + Sheep
    • City: Wheat + Wheat + Wheat + Ore + Ore