< Back

Assignment 6

This is a pair assignment. You should create a directory called assignment6 in cs120/assignments for this assignment. All code written for this assignment should be stored in that directory.

$ cd ~/cs120/assignments
$ mkdir assignment6$ cd assignment6


Monopoly

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 more strategic is to buy the locations that are most commonly landed on during the course of a Monopoly game. For this assignment, you will determine what 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.


Creative: Platformer

Two of the most popular 2D game genres are platform games, think Mario, and top-down games, think Zelda. The main difference between these types of games is that in a platform game the primary play mechanic is jumping. In this assignment you will create a game that uses either of these styles.

Details

Create a Python program that uses the graphics.py and sprite.py modules to recreate an educational video game. The game can be anything you want, but must do the following:

  1. Be a platform game or a top-down game.
  2. Use a list of sprites.
  3. Have a player-controlled sprite that interacts with the sprites in the list
  4. Have the ability to win or lose.
  5. Be impressive.

Extra

Exceptional games will receive extra credit. I will be the arbiter of whether a game is exceptional .


Your program should include the traditional header, use appropriate variable names, and nicely label all values printed to the terminal. Submission are to be done through inquire.roanoke.edu through the Assignment 6 link. Both partners must submit through inquire!