number_of_rounds = 50
player1 = 'Steven'
player2 = 'Edward'
choices = {

# create a dataframe of rock beats scissors etc.
import pandas as pd
winlose = pd.DataFrame(columns=['Rock','Paper','Scissors'])
winlose['Rock'] = ['Tie','Win','Loss']
winlose['Paper'] = ['Loss','Tie','Win']
winlose['Scissors'] = ['Win','Loss','Tie']
winlose.index = ['Rock','Paper','Scissors']

from random import choices as c
p1wins = 0
p2wins = 0
ties = 0
p1c = ''
p2c = ''
results = pd.DataFrame(columns=['Tie']) # so that 'Tie' is listed below the others in the chart
for x in range(number_of_rounds+1):
    results = results.append({player1+' Choice':p1c, player2+' Choice':p2c, 'Tie':ties, player2:p2wins, player1:p1wins}, ignore_index=True)
    p1c = c(choices[player1])[0]
    p2c = c(choices[player2])[0]
    result =[p1c, p2c]
    if result == 'Win':
        p1wins += 1
    if result == 'Loss':
        p2wins +=1
    if result == 'Tie':
        ties += 1

# convert wide dataframe to tidy
results['Round'] = results.index
tidy_results = results.drop(columns=[player1+' Choice', player2+' Choice']).melt('Round', var_name='Player', value_name='Wins')        

import as px
fig =, y='Player', x='Wins', orientation='h', animation_frame='Round', color='Player')
fig.update_layout(xaxis_range=[0,tidy_results['Wins'].max()+1], showlegend=False)
fig.update_layout(title='Rock Paper Scissors Tournament to '+str(number_of_rounds))

Results Data

Let's have a look at the table of results from that tournament by running the following code cell.


We can also count how many times a player chose each of the options:

results['Edward Choice'].value_counts()

Or display the round choices for all of the players:

for column in results.columns:
    if 'Choice' in column:

Determining the Winner of a Round

We can see the winlose table by running the following cell. Player 1's choice is the index column and Player 2's choice is the colunn headings.


To check if Player 1 wins by choosing Rock when Player 2 chooses Paper, we can use the following code.['Rock','Paper']


Try editing the first code cell to have different matches, for example Bart versus Freddie.

If you are feeling even more adventurous, try adjusting the code to have them play Rock Paper Scissors Lizard Spock. License