War Algorithm:
- Start
- Load in card files.
- Randomize the order of the Cards array.
- Set PlayerDeck and ComputerDeck to be filled with 26 random cards.
- While loop that ends when the someone runs out of cards.
- If PlayerDeck Value> ComputerDeck Value Add ComputerDeck(1) to PlayerDeck and remove ComputerDeck(1).
- . If PlayerDeck Value<ComputerDeck Value add PlayerDeck(1) to ComputerDeck and remove PlayerDeck(1).
- 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).
- Continue until someone runs out of cards. Loop will break.
- End.
Yahtzee Algorithm:
- Start
- Load Dice
- Set up the scoreboard
- Create a 48 turn counter
- Get a set of 5 random dice
- Ask the person what dice they would like to reroll
- reroll and display the new dice
- Ask the player if they want to reroll the previously rerolled dice
- Display all the dice
- Ask the player what category they want to use the dice for or if they want to skip
- If they want to skip go back to step 5
- If not continue
- Check if that category has already been filled
- if it has go back to step 9 and say that category is already used
- if it isn’t filled move on
- Check the dice to make sure that the dice fit that category
- A. If the dice work continue
- B. If the dice don’t fit then go back to step 9 and say that the dice don’t fit that category
- Add up the points gained and add them to the scoreboard
- Check if the upper total is greater than 63 points added up
- If so add bonus points continue
- If not continue
- Subtract 1 turn from the turn counter
- 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
- If the turn counter is equal to or less than 0 move on
- Check if the players have tied
- if they have print out the players tie
- If not move on
- Check which player has the greatest total points and print out which player wins
- End