Pseudocode (for all games)

Algorithm for Memory:

  1. Start
  2. Shuffle deck of 24 cards
  3. Lay out deck face down in row
  4. Pick card 1-24 for card 1 that is not flipped over, flip.
  5. Pick card 1-24 that is not card 1 and not flipped over, flip.
  6. If card 1 = card 2, leave face up. Display “awesome!”. If not, continue to step 7
  7. If card 1 =/= card 2, flip back over. Display “try again”
  8. If cards remain flipped over, return to step 4. If all cards are flipped over, continue.
  9. End

 

Algorithm for Under 7 over 7:

 

  1. Start
  2. Input starting amount of money
  3. Place bet. Bet must be less than or equal to money
  4. Guess if roll sum is under 7, over 7, or equal to 7.
  5. If guess = roll sum, add bet to money. If not, continue.
  6. If guess =/= roll sum, subtract bet from money.
  7. If money > 0, return to step 3
  8. If money = 0, continue.
  9. end

Leave a Reply

Your email address will not be published. Required fields are marked *