D. Final Algorithm, Flowchart, or Pseudocode

Memory:

  • Questions:
    • Do you get to choose how many pairs of cards to play with?
    • Does the game count the number of turns it takes?
    • Does the game inform the player all cards that have been removed at the start of each round?
  • Considerations:
    • Each card is stored in a vector, the index is the “Card” and the value of each card is randomly assigned to two of the indexes of the vector.
    • Sanitize inputs for non-numerical or out-of-bounds inputs.
    • When a pair is found, set the indexes of the pair to zero. Use a value of zero to check if a card is “in your hand” as opposed to “in play”.
  • Game starts:
    • Print to screen, ask for two inputs:
      • “Shows the cards on the screen with graphics”
      • “Please input a number 1 through 5 for the first hand: “
      • “This card has a [C] on it.”
      • “Please input a card 1 through 5 for the second hand : “
      • “This card has a [D] on it.”
    • Potential Errors:
      • “You already selected this card! Try again: “
      • “This card is already in your hand! Try again:”
    • Potential Outputs:
      • “The cards were a match! [A] and [B] have been placed in your hand!”
      • “The cards didn’t match! Try again!”
    • End of game:
      • “Congratulations! You win.”
      • “Would you like to play again? Press 1 to play again and 2 to exit: “

Yahtzee:

Yahtzee takes 13 rounds. At the start of every round, you roll *all* dice. After rolling, you can either score the current roll, or re-roll any one or more of the five dice. You can re-roll up to twice before you must be scored.

  • Questions:
    • Can the player request rules before the game starts? Or help during the game? Some rules are convoluted.
  • Considerations:
    • Scoring categories are stored in one vector with the following rules:
      • For each category, a value of [-1] means the category is Unscored.
      • For any other value, that is the score of the category.
      • Storing in a single vector makes selecting a category easier since the category number is just the vector index.
    • Dice rolls are stored in a vector. Re-rolls are stored in another vector with all values at 0.
      • When the player selects a die to re-roll, the index of that die is set to 1.
      • When the re-roll occurs, the index of all dice with a 1 are re-rolled, and then the re-roll vector is reset to all zeros.
    • You can actually get multiple Yahtzees, and you get bonus points for getting multiple.
      • If doing so, you get some convoluted “Joker Rules”
    • Sanitize all inputs so that if the player inputs something not prompted for, it asks them again instead of crashing.
  • Game starts:
    • Print to screen:
      • “Welcome to Yahtzee!”
      • “Round [1-13]:”
      • “Your starting rolls are: [A], [B], [C], [D], [E]”
      • “Enter the number of a die you would like to re-roll [1-5] or [0] to score the current roll: ” (Appears up to twice)
      • “Enter an additional die, or [0] to re-roll the currently selected dice: “
      • “Re-rolled! Your new dice are: [A], [B], [C], [D], [E]” (Only after 2nd re-roll)
      • “Time to score the current roll! Here is your scorecard:”
        • “[1] Aces (Ones): Unscored”
        • “[2] Twos: Unscored”
        • “[3] Threes: Unscored”
        • “[4] Fours: Unscored”
        • “[5] Fives: Unscored”
        • “[6] Sixes: Unscored”
        • “[7] 3 of a Kind: Unscored”
        • “[8] 4 of a Kind: Unscored”
        • “[9] Full House: Unscored (Worth 25 points)”
        • “[10] Small Straight: Unscored (Worth 30 points)”
        • “[11] Large Straight: Unscored (Worth 40 points)”
        • “[12] YAHTZEE: Unscored (Worth 50 points)”
        • “[13] Chance: Unscored”
      • “Please select a scoring category for your current roll [1-13]: “
      • “Your current roll: [A], [B], [C], [D], [E]”
      • “You scored [W] points in [X] category!”
    • Potential Errors:
      • “You’ve already scored that category! Please select a category you haven’t scored in yet [1-13]: “
      • “You don’t meet the qualifications to score in this category! Would you like to enter a 0 for this category? [1 for Yes]: “
    • Potential Outputs:
      • “BONUS YAHTZEE! Since you’ve already scored a Yahtzee, you get 100 bonus points!”
        • “Following Joker Rules, this roll will be scored as [X]”
        • “Following Joker Rules, you must enter a 0 in one of the Upper Section categories [1-6]: “
    • End of game:

      • “All categories have been scored! Game over!”
      • “You received [W] Bonus Yahtzee points.” (Only show if the player received any Bonus Yahtzee points)
      • “You received a 35-point bonus for scoring more than 63 points in the Upper Section!” (Only show if true)
      • “Your score was [X] for the Upper Section, and [Y] for the Lower Section.”
      • “Your total score comes to: [Z] points!”
      • “Would you like to play again? [1 or 0]: “