RPS

Hey everyone!

This week in programming, we made our own Rock-Paper-Scissors in trinket.io.
We used a base pdf that gave basic instructions on how to create the code, which included challenges of adding ASCII and making a more complex version. (I looked up more complex ASCII art versions of rock, paper, scissors, than the pdf had given because I wanted my program to look better).

This is the link to my normal Rock-Paper-Scissors game: https://trinket.io/python/fbcf910ec2

This is the link to my upgraded Rock-Paper-Scissors-Lizard-Spock game: https://trinket.io/python/04a6a79c78

Making the normal RPS game was pretty easy, as I was just following the pdf instructions. I had to ask the player for this choice of RPS, then define their answers in terms of pictures, then have the computer choose a random integer, that then corresponds to rock, paper, or scissors. I then defined the computer's answer in terms of pictures also. Lastly, I had to use if and elif functions to accurately print who won the game. I understand branching commands, which was the basis of this project, so it wasn't super difficult. I had to remember to use three single quotes when using the print commands for my ASCII art. One thing with that that I learned was if the picture itself had 3 single quotes, as part of the picture, it messed up the whole command. I had this happen with one of my pictures. To fix it, I just deleted one of the quotes and did whatever I had to add to make the picture look good again. Another thing that I learned was to start using #comments, which turn green and are not a part of the code, to help organize the code. As the codes are getting longer, these little notes to myself make fixing mistakes a lot easier.

I then copied the entirety of my code into a brand new tab of trinket.io, to make the upgraded version of Rock-Paper-Scissors-Lizard-Spock. While this was more complex, it was all repetitive work, so I did not find it very hard. For the player, I had to add coding for if the player entered 'lizard' and/or 'Spock' (*I learned that the input function is case sensitive. This means that in my input command I wrote capitalized 'Spock', so if the user entered lowercase 'spock', my code would not work. I could probably find an easy way to get around this, by defining both upper case and lower case.*) I also added ASCII art for these two. Then for the computer, I had to change the randint to (1,5), since now there were 5 options. I then proceeded to define 'lizard' and 'Spock' for the computer. The most time consuming part was deciding who won. I organized it by each option the player has (RPSLSp), and then pairing it with every option the computer has (RPSLSp). This resulted in 4 elif statements for if the player == 'rock'. This resulted in 20 elif functions. I kept the 'if player == computer:) statement, because I still wanted a draw if both entered the same thing.

I liked this project, as it solidified the concepts learned in pythonroom. I was also able to help my classmates, Jordan, Kayla, and Caffrey whenever they had problems.
One tip I have for anyone that has a code with an error, is to go line-by-line, making sure you understand what each command is doing. Make sure there's spaces where there needs to be spaces, make sure indents are the correct (some people accidentally used a space when they needed a tab, which messed up their code), and make sure everything is spelt correctly.

Just a little note that I'm applying Early Action for colleges, and this week has been very stressful.

Until next week when I (hopefully) have my applications in!

-Mimi





Comments