Python Rock Paper Scissors Game
Planning
The first thing that I always do before coding a larger program is plan my game. I usually get out a piece of paper and sketch out my ideas for the different functions, variables and the user interface (the text screen).
Player Choice Function
The first function that we are going to develop is the playerChoice() function.
This function will:
- Ask the user for an input
- Check if it is an acceptable input
- If it isn’t repeat the process of asking
- If it is, return either rock, scissors or paper.
Computer Choice Function
The next function we will create is the computer choice function
This function will:
- Pick a random choice from the list [“rock”,”paper”,”scissors”]
- Return the choice
Play a round function
The next part of our program is the play a round function. Here we will start to combine the other functions to make a basic working version of the game.
Main Function
Finally we pull the whole thing together with a main function. The job of this function is to:
- Run the code for each round
- Keep track of the round
- Keep track of the score
- Print out the final score
Complete Game Code