Flowchart: Connect 4
- Start game
- Hit 2 to start game and press ENTER
- You now use the red chips and the other player uses the black chips
- 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
- 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
- The next player places their chip based on the rules of the game and turns alternate between the two players.
- 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.
- The game is over once a player wins or there are no more spaces left on the board.
- 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)
- Load in the card deck and pick up the deck used for the game
- Assign the value of the cards in the deck
- Shuffle cards
- 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
- Quit the game and prompt a message to inform the user they have quit the game
- 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
- Prompt and ask the user whether he/she wants another card. Yes-go step8 No-go step9
- Hand another card to the player and show the card to the player.Go step7.
- Calculate the value of the cards on the dealer’s hand(Consider aces as 1)
- 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
- Judge whether the value of cards in the dealer’s hand is not bigger than 11. Yes-go step12 No-go step13
- Add 10 to the value of the dealer’s hand.go step 13
- Judge whether the value of the dealer’s hand is larger than17. Yes-go step15 No-go step14
- Hand another card to the dealer.Go step9
- Ask the player whether to have another card or not. Yes-go step16 No-go step17
- Hand another card to the player.Go step 15
- Check whether there are aces in the player’s hand. Yes-go step18 No-go step 19
- Ask the dealer how many aces does he want to consider as 11
- Calculate the value of the player’s hand
- Calculate the value of the dealer’s hand
- Compare the value of dealer and player.
- Print the winner
- Exit