Modular Breakdown

Learn to break down the game into its components.

We'll cover the following

How to start

Before we delve into the coding aspects of this project, let’s spend some time understanding its workflow. A strong understanding of the project and its requirements will go a long way in helping us as we build our project. Based on what we observed while playing the game in the previous lesson, let’s go through the logical breakdown of the program step by step.

  • Display instructions: Present the rules and instructions of the game to the user so they understand how to play.

  • Input number of rounds: Prompt the user to enter how many rounds they want to play.

  • Input user’s choice: Ask the user to choose between rock, paper, or scissors for the current round.

  • Determine the computer’s choice: To determine the computer’s choice, randomly select rock, paper, or scissors.

  • Check round winner and update score: Compare the user’s choice and the computer’s choice to determine the round’s winner and update the scores accordingly.

  • Check if all rounds are done: Verify if the specified number of rounds has been played. If not, loop back to input the user’s choice for the next round.

  • Determine winner: After all rounds are completed, compare the final scores to determine the overall winner of the game.

  • Display results: Show the final results, including the scores and the overall winner, to the user.

Press + to interact
Rock, paper, scissors flowchart
Rock, paper, scissors flowchart

With the program structure broken down, we now have a better understanding of the problem. In the rest of the course, our aim will be to create functions that can carry out each of these tasks and join them together to achieve the final functionality we desire.

Game flow revisited

Let’s play the game once again. This time, try to map the program flow to each step in the flowchart and ensure you understand how this program for the rock, paper, scissors game works.