D. Final Algorithm, Flowchart, or Pseudocode

War Algorithm: 

 

  1. Start
  2. Load in card files.
  3. Randomize the order of the Cards array.
  4. Set PlayerDeck and ComputerDeck to be filled with 26 random cards.
  5.  While loop that ends when the someone runs out of cards.
  6. If PlayerDeck Value> ComputerDeck Value Add ComputerDeck(1) to PlayerDeck and remove ComputerDeck(1).
  7. . If PlayerDeck Value<ComputerDeck Value add PlayerDeck(1) to ComputerDeck and remove PlayerDeck(1).
  8. If PlayerDeck Value= ComputerDeck Value, Compare PlayerDeck(4) and ComputerDeck(4), if PlayerDeck(4)> ComputerDeck(4) add ComputerDeck(1:4) to PlayerDeck and remove ComputerDeck(1:4). If PlayerDeck(4)<ComputerDeck(4) add PlayerDeck(1:4) to ComputerDeck and remove PlayerDeck(1:4).
  9. Continue until someone runs out of cards. Loop will break.
  10. End.

Yahtzee Algorithm:

  1. Start
  2. Load Dice
  3. Set up the scoreboard
  4. Create a 48 turn counter
  5. Get a set of 5 random dice
  6. Ask the person what dice they would like to reroll
  7. reroll and display the new dice
  8. Ask the player if they want to reroll the previously rerolled dice
  9. Display all the dice
  10. Ask the player what category they want to use the dice for or if they want to skip
    1. If they want to skip go back to step 5
    2. If not continue
  11. Check if that category has already been filled
    1. if it has go back to step 9 and say that category is already used
    2. if it isn’t filled move on
  12. Check the dice to make sure that the dice fit that category
    1. A. If the dice work continue
    2. B. If the dice don’t fit then go back to step 9 and say that the dice don’t fit that category
  13. Add up the points gained and add them to the scoreboard
  14. Check if the upper total is greater than 63 points added up
    1. If so add bonus points continue
    2. If not continue
  15. Subtract 1 turn from the turn counter
    1. If the turn counter is greater than 0 go back to step 5 storing the next players scores in a different column of the scoreboard
    2. If the turn counter is equal to or less than 0 move on
  16. Check if the players have tied
    1. if they have print out the players tie
    2. If not move on
  17. Check which player has the greatest total points and print out which player wins
  18. End