CSCI 200 - Foundational Programming Concepts & Design - Fall 2022

A4 - Wild Left-Center-Right Simulation

→This assignment is due by Tuesday, November 01, 2022, 11:59 PM.←
→ As with all assignments, this must be an individual effort and cannot be pair programmed. Any debugging assistance must follow the course collaboration policy and be cited in the comment header block for the assignment.←
→ Do not forget to complete the following labs with this set: L4A, L4B, L4C
→ Do not forget to complete zyBooks Assignment 4 for this set.←

· Instructions · Rubric ·Submission ·

We're going to create a game simulation of several people playing Left-Center-Right. If you aren't familiar with the rules, here's a two minute summary of the game play: LCR Video Explanation.

The requirements for this assignment are more abstractly defined and the implementation is left to your choosing. However, you will need to defend the choices you made in your implementation.


Object Structure


We'll need to create several concepts to the computer:

  1. A Player
  2. A Die
  3. A Game

Player

The Player will have two attributes that track its state:

The Player will have several behaviors associated with its state:

The Die

We'll take a simple approach to a die. We'll simulate it by generating a random number. Our game will use an 8-sided die so you'll want to generate a random number in the range [0, 7]. The possible values map to the following outcomes:

The Game

The game is where the all the logic will be kept. We'll use a Circular Doubly Linked List to keep track of all the players. The game will need to track several values:

The gameplay will be implemented with the following pseudocode:

As this is a simulation, once we start the program it will run automatically by itself until the end of the game is reached. To inform the user what is occurring, print a message to the standard out with what is occurring. An example run of the game is shown below:

> ./A5
How many players are playing: 2
Player #1 has 3 chips left
        Rolling 3 dice
        Rolled a 7 - skip! skipping 1 players
        Rolled a 0 - keep!
        Rolled a 4 - give right - Player #2 has 4 chips - Player #1 has 2 chips
Player #1 has 2 chips left
        Rolling 2 dice
        Rolled a 1 - keep!
        Rolled a 3 - give left - Player #2 has 5 chips - Player #1 has 1 chips
Player #2 has 5 chips left
        Rolling 3 dice
        Rolled a 0 - keep!
        Rolled a 3 - give left - Player #1 has 2 chips - Player #2 has 4 chips
        Rolled a 4 - give right - Player #1 has 3 chips - Player #2 has 3 chips
Player #1 has 3 chips left
        Rolling 3 dice
        Rolled a 2 - keep!
        Rolled a 5 - give center - Center has 1 chips - Player #1 has 2 chips
        Rolled a 5 - give center - Center has 2 chips - Player #1 has 1 chips
Player #2 has 3 chips left
        Rolling 3 dice
        Rolled a 6 - reverse!
        Rolled a 7 - skip! skipping 1 players
        Rolled a 7 - skip! skipping 2 players
Player #1 has 1 chips left
        Rolling 1 dice
        Rolled a 6 - reverse!
Player #2 has 3 chips left
        Rolling 3 dice
        Rolled a 7 - skip! skipping 1 players
        Rolled a 0 - keep!
        Rolled a 4 - give right - Player #1 has 2 chips - Player #2 has 2 chips
Player #2 has 2 chips left
        Rolling 2 dice
        Rolled a 5 - give center - Center has 3 chips - Player #2 has 1 chips
        Rolled a 3 - give left - Player #1 has 3 chips - Player #2 has 0 chips
Player #1 wins with 3 chips left after 8 turns

The two player game shows some features of the circular linked list. Left and Right correspond to the same player. Reverse has no apparent effect. Skipping one player returns to the same player.

Another play with more players is shown below.

> ./A5
How many players are playing: 3
Player #1 has 3 chips left
        Rolling 3 dice
        Rolled a 2 - keep!
        Rolled a 7 - skip! skipping 1 players
        Rolled a 3 - give left - Player #2 has 4 chips - Player #1 has 2 chips
Player #3 has 3 chips left
        Rolling 3 dice
        Rolled a 3 - give left - Player #1 has 3 chips - Player #3 has 2 chips
        Rolled a 6 - reverse!
        Rolled a 0 - keep!
Player #2 has 4 chips left
        Rolling 3 dice
        Rolled a 0 - keep!
        Rolled a 1 - keep!
        Rolled a 1 - keep!
Player #1 has 3 chips left
        Rolling 3 dice
        Rolled a 2 - keep!
        Rolled a 1 - keep!
        Rolled a 0 - keep!
Player #3 has 2 chips left
        Rolling 2 dice
        Rolled a 0 - keep!
        Rolled a 7 - skip! skipping 1 players
Player #1 has 3 chips left
        Rolling 3 dice
        Rolled a 6 - reverse!
        Rolled a 7 - skip! skipping 1 players
        Rolled a 3 - give left - Player #2 has 5 chips - Player #1 has 2 chips
Player #3 has 2 chips left
        Rolling 2 dice
        Rolled a 0 - keep!
        Rolled a 3 - give left - Player #1 has 3 chips - Player #3 has 1 chips
Player #1 has 3 chips left
        Rolling 3 dice
        Rolled a 3 - give left - Player #2 has 6 chips - Player #1 has 2 chips
        Rolled a 0 - keep!
        Rolled a 6 - reverse!
Player #3 has 1 chips left
        Rolling 1 dice
        Rolled a 6 - reverse!
Player #1 has 2 chips left
        Rolling 2 dice
        Rolled a 2 - keep!
        Rolled a 3 - give left - Player #2 has 7 chips - Player #1 has 1 chips
Player #2 has 7 chips left
        Rolling 3 dice
        Rolled a 5 - give center - Center has 1 chips - Player #2 has 6 chips
        Rolled a 6 - reverse!
        Rolled a 7 - skip! skipping 1 players
Player #3 has 1 chips left
        Rolling 1 dice
        Rolled a 4 - give right - Player #2 has 7 chips - Player #3 has 0 chips
Player #2 has 7 chips left
        Rolling 3 dice
        Rolled a 5 - give center - Center has 2 chips - Player #2 has 6 chips
        Rolled a 3 - give left - Player #3 has 1 chips - Player #2 has 5 chips
        Rolled a 5 - give center - Center has 3 chips - Player #2 has 4 chips
Player #1 has 1 chips left
        Rolling 1 dice
        Rolled a 0 - keep!
Player #3 has 1 chips left
        Rolling 1 dice
        Rolled a 5 - give center - Center has 4 chips - Player #3 has 0 chips
Player #2 has 4 chips left
        Rolling 3 dice
        Rolled a 5 - give center - Center has 5 chips - Player #2 has 3 chips
        Rolled a 7 - skip! skipping 1 players
        Rolled a 6 - reverse!
Player #1 has 1 chips left
        Rolling 1 dice
        Rolled a 7 - skip! skipping 1 players
Player #1 has 1 chips left
        Rolling 1 dice
        Rolled a 2 - keep!
Player #2 has 3 chips left
        Rolling 3 dice
        Rolled a 1 - keep!
        Rolled a 0 - keep!
        Rolled a 4 - give right - Player #1 has 2 chips - Player #2 has 2 chips
Player #1 has 2 chips left
        Rolling 2 dice
        Rolled a 3 - give left - Player #2 has 3 chips - Player #1 has 1 chips
        Rolled a 0 - keep!
Player #2 has 3 chips left
        Rolling 3 dice
        Rolled a 2 - keep!
        Rolled a 4 - give right - Player #1 has 2 chips - Player #2 has 2 chips
        Rolled a 0 - keep!
Player #1 has 2 chips left
        Rolling 2 dice
        Rolled a 0 - keep!
        Rolled a 1 - keep!
Player #2 has 2 chips left
        Rolling 2 dice
        Rolled a 3 - give left - Player #3 has 1 chips - Player #2 has 1 chips
        Rolled a 7 - skip! skipping 1 players
Player #1 has 2 chips left
        Rolling 2 dice
        Rolled a 5 - give center - Center has 6 chips - Player #1 has 1 chips
        Rolled a 3 - give left - Player #2 has 2 chips - Player #1 has 0 chips
Player #2 has 2 chips left
        Rolling 2 dice
        Rolled a 5 - give center - Center has 7 chips - Player #2 has 1 chips
        Rolled a 5 - give center - Center has 8 chips - Player #2 has 0 chips
Player #3 wins with 1 chips left after 25 turns

Hints



Exit Interview


When completed, create a README.txt file and respond to the following questions:

  1. How did you structure your Player?
  2. How did you structure your Game?
  3. How did you make use of classes and functions? What went where?

Extra Credit


Very often games give an indication how long it will take to complete a game. Now that we have a simulation in place, we can begin running some simulations to calculate some statistics. Modify your program to ask the user how many games they wish to simulate. After each game, track how many turns it took to complete. After all games have finished, print the average number of turns per game.

We can now compute this statistic for a variety of number of players. Add to your README.txt a table of the following form:

# Players | # Turns
----------|--------
     2    |
     3    |
     4    |
     5    |
    10    |
    20    |

And fill in the average number of turns. Answer the following two questions in your README.txt

  1. How many simulations did you need to run to reach a stable average?
  2. What is the relationship between the number of players and the number of turns? Linear? Quadratic? Exponential? Other?

Testing


The graders will build your program with the Makefile you provide to match your code structure.


Best Practices To Follow



Grading Rubric


Your submission will be graded according to the following rubric.

PointsRequirement Description
15 All labs completed and submitted
L4A, L4B, L4C
5 Player class created and implemented correctly
5 Circular Doubly Linked List created and implemented correctly
12 Each of the eight die rolls handled correctly
8 Game play runs correctly
5 Game ends under correct conditions
+4 A4 Extra Credit Completed.
5 Best practices are followed:
  • +5 Code is easily readable, follows best practices, well structured
  • +4 Code is easy to follow, only a few small violations of best practices
  • +3 No egregiously bad practices
  • +2 Lots of violations of best practices
  • +1 Little effort to follow best practices
  • +0 No effort to follow best practices
55 Total Points

→This assignment is due by Tuesday, November 01, 2022, 11:59 PM.←
→ As with all assignments, this must be an individual effort and cannot be pair programmed. Any debugging assistance must follow the course collaboration policy and be cited in the comment header block for the assignment.←
→ Do not forget to complete the following labs with this set: L4A, L4B, L4C
→ Do not forget to complete zyBooks Assignment 4 for this set.←


Submission


Always, always, ALWAYS update the header comments at the top of your main.cpp file. And if you ever get stuck, remember that there is LOTS of help available.

It is critical that you follow these steps when submitting homework.

If you do not follow these instructions, your assignment will receive a major deduction. Why all the fuss? Because we have several hundred of these assignments to grade, and we use computer tools to automate as much of the process as possible. If you deviate from these instructions, our grading tools will not work.


Submission Instructions



Here are step-by-step instructions for submitting your homework properly:

  1. Make sure you have the appropriate comment header block at the top of every source code file for this set. The header block should include the following information at a minimum.
    /* CSCI 200: Assignment 4: A4 - Wild Left-Center-Right Simulation
     *  * Author: XXXX (INSERT_NAME) * Resources used (Office Hours, Tutoring, Other Students, etc & in what capacity):  * // list here any outside assistance you used/received while following the * // CS@Mines Collaboration Policy and the Mines Academic Code of Honor *  * XXXXXXXX (MORE_COMPLETE_DESCRIPTION_HERE)  */
    Be sure to fill in the appropriate information, including:
    • Assignment number
    • Assignment title
    • Your name
    • If you received any type of assistance (office hours - whose, tutoring - when), then list where/what/who gave you the assistance and describe the assistance received
    • A description of the assignment task and what the code in this file accomplishes.

    Additionally, update the Makefile for A4 to generate a target executable named A4.

  2. File and folder names are extremely important in this process. Please double-check carefully, to ensure things are named correctly.
    1. The top-level folder of your project must be named Set4
    2. Inside Set4, create 4 sub-folders that are required for this Set. The name of each sub-folder is defined in that Set (e.g. L4A, L4B, L4C, and A4).
    3. Copy your files into the subdirectories ofSet4 (steps 2-3), zip this Set4 folder (steps 4-5), and then submit the zipped file (steps 6-11) to Canvas.
    4. For example, when you zip/submit Set4, there will be 4 sub-folders called L4A, L4B, L4C, and A4 inside the Set4 folder, and each of these sub-folders will have the associated files.

  3. Using Windows Explorer (not to be confused with Internet Explorer), find the files named main.cpp, Makefile, README.txt, *.h, *.hpp, *.cpp.

    STOP: Are you really sure you are viewing the correct assignment's folder?

  4. Now, for A4, right click on main.cpp, Makefile, README.txt, *.h, *.hpp, *.cpp to copy the files. Then, return to the Set4/A4 folder and right click to paste the files. In other words, put a copy of your homework's main.cpp, Makefile, README.txt, *.h, *.hpp, *.cpp source code into the Set4/A4 folder.

    Follow the same steps for each lab to put a copy of each lab's deliverable into the Set4/L4 folders. Do this process for Set4/L4A (linked_list_functions.cpp), Set4/L4B (LinkedList.h, LinkedList.cpp), Set4/L4C (Node.hpp, LinkedList.hpp, main.cpp, Makefile).

    STOP: Are you sure your Set4 folder now has all your code to submit?

    The structure of the submission is as follows:
    • Set4/
      • A4/
        • main.cpp
        • Makefile
        • README.txt
        • *.h
        • *.hpp
        • *.cpp
      • L4A/
        • linked_list_functions.cpp
      • L4B/
        • LinkedList.h
        • LinkedList.cpp
      • L4C/
        • Node.hpp
        • LinkedList.hpp
        • main.cpp
        • Makefile

  5. Now, right-click on the "Set4" folder.
    1. In the pop-up menu that opens, move the mouse "Send to..." and expand the sub-menu.
    2. In the sub-menu that opens, select "Compressed (zipped) folder".

    STOP: Are you really sure you are zipping a Set4 folder with sub-folders that each contain a main.cpp file in it?

  6. After the previous step, you should now see a "Set4.zip" file.

  7. Now visit the Canvas page for this course and click the "Assignments" button in the sidebar.

  8. Find Set4, click on it, find the "Submit Assignment" area, and then click the "Choose File" button.

  9. Find the "Set4.zip" file created earlier and click the "Open" button.

    STOP: Are you really sure you are selecting the right homework assignment? Are you double-sure?

  10. WAIT! There's one more super-important step. Click on the blue "Submit Assignment" button to submit your homework.

  11. No, really, make sure you click the "Submit Assignment" button to actually submit your homework. Clicking the "Choose File" button in the previous step kind of makes it feel like you're done, but you must click the Submit button as well! And you must allow the file time to upload before you turn off your computer!

  12. Canvas should say "Submitted!". Click "Submission Details" and you can download the zip file you just submitted. In other words, verify you submitted what you think you submitted!

In summary, you must zip the "Set4" folder and only the "Set4" folder, this zip folder must have several sub-folders, you must name all these folders correctly, you must submit the correct zip file for this homework, and you must click the "Submit Assignment" button. Not doing these steps is like bringing your homework to class but forgetting to hand it in. No concessions will be made for incorrectly submitted work. If you incorrectly submit your homework, we will not be able to give you full credit. And that makes us unhappy.


→This assignment is due by Tuesday, November 01, 2022, 11:59 PM.←
→ As with all assignments, this must be an individual effort and cannot be pair programmed. Any debugging assistance must follow the course collaboration policy and be cited in the comment header block for the assignment.←
→ Do not forget to complete the following labs with this set: L4A, L4B, L4C
→ Do not forget to complete zyBooks Assignment 4 for this set.←