# D. Final Algorithm, Flowchart, or Pseudocode

Flowchart: Connect 4

1. Start game
2. Hit 2 to start game and press ENTER
3. You now use the red chips and the other player uses the black chips
4. Press which row you want to place your chip in based on the rules of the game with the bottom most row being 6 and hit enter
5. Press which column you want to place your chip in based on the rules of the game with the far-left column being 1 and hit enter
6. The next player places their chip based on the rules of the game and turns alternate between the two players.
7. If there are four chips in a row at any point in the game either horizontally, vertically, or diagonally, then the player who uses those colored chips win.
8. The game is over once a player wins or there are no more spaces left on the board.
9. If there is a tie then the game automatically exits. If there is a winner, then one of the players must press CTRL+C

Algorithm (Blackjack)

1. Load in the card deck and pick up the deck used for the game
2. Assign the value of the cards in the deck
3. Shuffle cards
4. Prompt and present the user the rule of the game and ask them whether they want to accept the rules and play the game or not. Yes-go step 6 No-go step 5
1. Quit the game and prompt a message to inform the user they have quit the game
2. Hand out two cards to the player and two cards to the dealer and show all the cards of the player and one card from the dealer to the player
3. Prompt and ask the user whether he/she wants another card. Yes-go step8 No-go step9
1. Hand another card to the player and show the card to the player.Go step7.
2. Calculate the value of the cards on the dealer’s hand(Consider aces as 1)
3. Count the number of aces in the dealer’s hand. There are aces in the deal’s hand-go step11 There are no aces in the deal’s hand-go step
1. Judge whether the value of cards in the dealer’s hand is not bigger than 11. Yes-go step12 No-go step13
1. Add 10 to the value of the dealer’s hand.go step 13
2. Judge whether the value of the dealer’s hand is larger than17. Yes-go step15 No-go step14
1. Hand another card to the dealer.Go step9
2. Ask the player whether to have another card or not. Yes-go step16 No-go step17
1. Hand another card to the player.Go step 15
2. Check whether there are aces in the player’s hand. Yes-go step18 No-go step 19
1. Ask the dealer how many aces does he want to consider as 11
2. Calculate the value of the player’s hand
3. Calculate the value of the dealer’s hand
4. Compare the value of dealer and player.
5. Print the winner
6. Exit