CPSC120A
Fundamentals of Computer Science I

Scientific Assignment 6

Use Python for Game Theory Calculations.

Monopoly is a very competitive game played by people across the entire world. While there is a lot of luck involved in Monopoly, there is also a fair bit of strategy involved as well. Which real estate should you buy? The more real estate you own, the better. However that also costs a lot of money. The better strategy is to buy the locations that are most commonly landed on during the course of a Monopoly game. For this assignment, you will determine which spaces have the highest probability of being landed on.


Details

You are going to represent a Monopoly board as a list of 40 integers. These integers are going to represent the count of the number of times an arbitrary player lands on a particular space. You are going to estimate this probability using the monte carlo method. You are going to start with a player at Go! (array index 0). You will generate 2 random numbers in the range \([1, 6]\) (You cannot generate a random number in the range \([1, 12]\), since this will not create the same distribution as a dice roll of two dice). This will move the player to a new location on the board, and you will increment the value in that space. You will then perform this again, with the player at the new location.

If the player lands on Go to Jail, you should send them directly to Jail.

There are a lot of other more obscure rules. We are not going to worry about these rules (Such as rolling doubles 3 times in a row, etc.). The rules listed above are the only rules you need to worry about.

You should run this process until the player has made 1,000 trips around the entire board. After the player has made the required number of trips around the board, you will output a list of all the probabilities for each of the locations on the board. The output should be nicely formatted so that you can use the image above to determine the board locations that have the highest probabiliby to be landed on during a single trip around the board.


"Hacker" Prompt

Each week, additional exercises related to the assignment will be provided at the end. These exercises are typically more challenging than the regular assignment. Bonus points will be provided to students who complete any of the "Hacker" level assignments.

  1. Doubles: In the real game of Monopoly, if you roll doubles 3 times in a row you go directly to jail. Modify your code above so that if a double is rolled 3 times in a row the user is sent directly to jail.

  2. Chance and Community Chest: While you will get decent results from above, you can do better if you handle the Community Chest (2, 17, 33) and Chance (36, 22, 7) locations. These locations have a certain probability to send you to another location on the board. For the Community Chest, there is a \(\frac{1}{16}\) chance of being sent to jail. For Chance, the distribution is a bit more complex:

    \(\frac{1}{16}\)
    Sent to Go! (00)
    \(\frac{1}{16}\)
    Sent to Reading Railroad (05)
    \(\frac{2}{16}\)
    Sent to the closest Railroad (05, 15, 25, 35)
    \(\frac{1}{16}\)
    Sent to Jail (10)
    \(\frac{1}{16}\)
    Sent to the closest Utility (12, 18)
    \(\frac{1}{16}\)
    Sent to St. Charles Place (11)
    \(\frac{1}{16}\)
    Sent to Illinois Ave. (24)
    \(\frac{1}{16}\)
    Sent to Boardwalk (39)
    \(\frac{1}{16}\)
    Sent back 3 spaces

    Alter the code to follow the above probabilities when you land on the appropriate squares.

  3. User Friendly Printing: The printout that you provided above was not very user friendly. It didn't even write out the names of the squares! Add code to your program so it outputs the name of the square, and its associated probability.


Grading

The assignment will be graded on the following requirements according to the course’s programming assignment rubric.

Functionality (75%): A functional program will:

Style (25%): A program with good style will:

Submission

Submit your program and any image files it uses as a .zip file on the course Inquire page before class on Monday November 23rd.