Rock, Paper, Scissors [-1]
de acaamanodejesus @acaamanodejesus
- 122
- 1
- 1
Introduction
The desicion for my projet was something that came out of nowhere. I started a few simple game projects for fun and Rock, Paper and scissors was one of them. I have a friend of mine that is a programmer and he gives me tips and challenges and this was one of those. He challenged me to do th version of the game that they play in the show Squid Games, in which they use both hands and then choose only one, the final desicion plays out as regular Rock, paper, scissors. Since I am having fun I decided to just do domething fun for my project.
![Rock, Paper, Scissors [-1] 1](https://imgproxy.domestika.org/unsafe/w:820/plain/src://content-items/016/850/876/data-original.png?1754859889)
Supplies
I used visual studio code with python and on the code itself I made the use of variables, the library random, custom functions, lists, dictionaries, loops, conditionals and if statements.
1.)Setting everything up
We started by importing the library random to generate sandon integers later, then we define some variables, lists, and a dictionary that will associate Rock, Paper and Scissors to the numbers 1, 2, 3.
After that we print a header for the game and define a function that will make sure that the user input a valid option by using a while loop that only breaks after 1, 2 or 3 is input. Shortly after we ask the user to input its choice and validate immediately with the previous defined function.
![Rock, Paper, Scissors [-1] 1](https://imgproxy.domestika.org/unsafe/w:820/plain/src://content-items/016/850/879/data-original.png?1754859889)
2.)Computer answer and final choice
at this point we use the random library to generate a random number between 1 and 3, this number will be compared against the dictionary to know which one is the answer. For the second one I added a while loop to make sure that the computer not answer the same thing twice because thta would be very easy to beat.
After that all the hands are compared and then the user gets to remove one of the two options by just typing 1 or 2.
![Rock, Paper, Scissors [-1] 1](https://imgproxy.domestika.org/unsafe/w:820/plain/src://content-items/016/850/881/data-original.png?1754859889)
3.) Final whowdown and end
For the computer we use randint to get random number between 1 and 2 and use it to decide which card is going to be eliminates, at the end we compare and determine the winner by using iff statements.
![Rock, Paper, Scissors [-1] 1](https://imgproxy.domestika.org/unsafe/w:820/plain/src://content-items/016/850/883/data-original.png?1754859889)
Conclusion
This one was good enought to have me doing different stuffs and also this code is something that could be used in the future or repurpose it. I ike the easy that it would be to expand the code.
![Rock, Paper, Scissors [-1] 1](https://imgproxy.domestika.org/unsafe/w:820/plain/src://content-items/016/850/885/data-original.png?1754859889)
1 comentário
Hola, excelente idea pra tu proyecto! Al hacer algo que sea de tu propia idea y ejecución aprendes mucho más.
Veo que utilizaste condicionales, iteraciones y funciones, está excelente. Buen uso de random para tu tipo de proyecto.
Espero te haya gustado el curso!
Faça login ou cadastre-se Gratuitamente para comentar