Hey I am trying to help with issue [#45731]( [Python] Incorrect User Stories · Issue #45731 · freeCodeCamp/freeCodeCamp (github.com))
but I am getting error
> git -c user.useConfigOnly=true commit --quiet --allow-empty-message --file - [STARTED] Preparing lint-staged... [SUCCESS] Preparing lint-staged... [STARTED] Running tasks for staged files... [STARTED] .lintstagedrc.js — 1 file [STARTED] *.(js|ts|tsx) — 0 file [STARTED] *.!(js|ts|tsx) — 1 file [STARTED] ./curriculum/challenges/**/*.md — 1 file [SKIPPED] *.(js|ts|tsx) — no files [STARTED] prettier --write --ignore-unknown '/workspace/freeCodeCamp/curriculum/cha… [STARTED] node ./tools/scripts/lint/index.js '/workspace/freeCodeCamp/curriculum/ch… [FAILED] node ./tools/scripts/lint/index.js '/workspace/freeCodeCamp/curriculum/challenges/english/11-machine-learning-with-python/machine-learning-with-python-projects/rock-paper-scissors.md' [FAILED] [FAILED] node ./tools/scripts/lint/index.js '/workspace/freeCodeCamp/curriculum/challenges/english/11-machine-learning-with-python/machine-learning-with-python-projects/rock-paper-scissors.md' [FAILED] [SUCCESS] Running tasks for staged files... [STARTED] Applying modifications from tasks... [SKIPPED] Skipped because of errors from tasks. [STARTED] Reverting to original state because of errors... [SUCCESS] Reverting to original state because of errors... [STARTED] Cleaning up temporary files... [SUCCESS] Cleaning up temporary files... ✖ node ./tools/scripts/lint/index.js '/workspace/freeCodeCamp/curriculum/challenges/english/11-machine-learning-with-python/machine-learning-with-python-projects/rock-paper-scissors.md': /workspace/freeCodeCamp/curriculum/challenges/english/11-machine-learning-with-python/machine-learning-with-python-projects/rock-paper-scissors.md: 40: MD031/blanks-around-fences Fenced code blocks should be surrounded by blank lines [Context: "```"] /workspace/freeCodeCamp/curriculum/challenges/english/11-machine-learning-with-python/machine-learning-with-python-projects/rock-paper-scissors.md: 42: MD031/blanks-around-fences Fenced code blocks should be surrounded by blank lines [Context: "```py"] /workspace/freeCodeCamp/curriculum/challenges/english/11-machine-learning-with-python/machine-learning-with-python-projects/rock-paper-scissors.md: 34: MD032/blanks-around-lists Lists should be surrounded by blank lines [Context: "- two players to play against ..."] husky - pre-commit hook exited with code 1 (error)
title: Rock Paper Scissors
For this challenge, you will create a program to play Rock, Paper, Scissors. A program that picks at random will usually win 50% of the time. To pass this challenge your program must play matches against four different bots, winning at least 60% of the games in each match.
You will be working on this project with our Replit starter code.
We are still developing the interactive instructional part of the machine learning curriculum. For now, you will have to use other resources to learn how to pass this challenge.
In the file
RPS.py you are provided with a function called
player. The function takes an argument that is a string describing the last move of the opponent (“R”, “P”, or “S”). The function should return a string representing the next move for it to play (“R”, “P”, or “S”).
A player function will receive an empty string as an argument for the first game in a match since there is no previous play.
RPS.py shows an example function that you will need to update. The example function is defined with two arguments (
player(prev_play, opponent_history = )). The function is never called with a second argument so that one is completely optional. The reason why the example function contains a second argument (
opponent_history = ) is because that is the only way to save state between consecutive calls of the
player function. You only need the
opponent_history argument if you want to keep track of the opponent_history.
Hint: To defeat all four opponents, your program may need to have multiple strategies that change depending on the plays of the opponent.
Do not modify
RPS_game.py. Write all your code in
RPS.py. For development, you can use
main.py to test your code.
main.py imports the game function and bots from
To test your code, play a game with the
play function. The
play function takes four arguments:
- two players to play against each other (the players are actually functions)
- the number of games to play in the match
- an optional argument to see a log of each game. Set it to
Trueto see these messages.
play(player1, player2, num_games[, verbose])
For example, here is how you would call the function if you want `player` and `quincy` to play 1000 games against each other and you want to see the results of each game: ```py play(player, quincy, 1000, verbose=True)
Click the “run” button and
main.py will run.
he unit tests for this project are in
test_module.py. We imported the tests from
main.py for your convenience. If you uncomment the last line in
main.py, the tests will run automatically whenever you hit the “run” button.
Copy your project’s URL and submit it below.
It should pass all Python tests.
# Python challenges don't need solutions, # because they would need to be tested against a full working project. # Please check our contributing guidelines to learn more.