The easygames library in Python
$ pip install oneplayergames
import easygames
winner = easygames.rock_paper_scissors()
This gets the input from the user, randomly generates one for the computer, and works out the winner.
- 0 if draw
- 1 if player wins
- 2 if computer wins
guesses = easygames.guess_the_number()
This gets the input from the user until the number is guessed correctly.
n: int (optional, default: 100) = Maximum number which can be the computer's number. In other words, the computer generates a random number from 1 to n.
Number of guesses it took for the user to guess the number correctly
num = easygames.fizz_buzz()
Count up from 1:
- if the number is a multiple of 3, type 'F' for 'Fizz'
- if the number is a multiple of 5, type 'B' for 'Buzz'
- if the number is a multiple of 3 and 5, type 'FB' for 'FizzBuzz'
- otherwise, just type the number
For example ('#' indicates comment)
1
2
F # instead of 3
4
B # instead of 5
F # instead of 6
7
8
F # instead of 9
B # instead of 10
11
F # instead of 12
13
14
FB # instead of 15
The number that the user got up to before making a mistake
Use the play
command
$ play rps
$ play gtn
$ play fb