Software Design and Implementation
A2: On python conditionalsAssignment A2 should be complete individually or in a pair. However, if you work in a pair, you must work together the whole time, and you must describe your roles in your program's comments.
Rock-Paper-Scissors is a game which is played between two people.If you do not already know who to play, the game is described in detail at http://en.wikipedia.org/wiki/Rock-paper-scissors.
We are going to create a variant of this came called Rock-Paper-Scissors-Spock-Lizard, which was created because the authors did not like all of the ties which occur in Rock-Paper-Scissors. This game is described in detail at http://en.wikipedia.org/wiki/Rock-paper-scissors-lizard-Spock
Basically, the user will choose one of rock, paper, scissors, spock, lizard, and the computer will choose one of these.
The rules of rock-paper-scissors-spock-lizard are:
- Scissors cut paper
- Paper covers rock
- Rock crushes lizard
- Lizard poisons Spock
- Spock smashes scissors
- Scissors decapitate lizard
- Lizard eats paper
- Paper disproves Spock
- Spock vaporizes rock
- Rock crushes scissors
Download yourusername-A2-three.py. Remember that you might have to right-click to download the python file. This program contains many ideas you will need for this assignment, so run it and look carefully at the various parts of the code. Then make modifications since you will need the random library as well as the
if, elif, elsestructure. To make this program work correctly, you will need a bunch of
elifs. You may also want to nest your
ifstatements, so the example shows that.
- Name your program yourusername-A2-rps.py.
- Your program should invite the user to play.
- Your program must repeat the choice the user made. You may
assume the user will type her/his choice correctly. Note that
case matters in python, so we recommend using lower case. Also,
since we are using Python 2.7.6, you must use the
raw_inputcommand to get user input.
- Your program must reveal the choice that the computer makes.
- Your program must print out who won that round (or whether it was a tie, or some other outcome...)
- Your program must include a large comment block at the top with your name, username, assignment number, purpose and acknowledgements.
- Your program must have explanatory comments in the code itself. Usually, these are added only where code might be confusing. When we are exploring a new construct in python, that would be a good place to add a comment.
- Optionally--please only do this after you finish the above, feel free to play around and add new fun parts to your program. For example, you could consider writing a second program which cheats. If you do this, please submit both versions. :)
- Upload yourusername-A2-rps.py to Moodle after correcting the filename.
Note that submitted files with incorrect filenames may not receive full credit because it makes grading more difficult for us and the TAs, so please check filenames carefully!