|
| 23 Jan 2016 03:04 PM |
| create a RockPaperScissors basic input output game where for the win/lose logic you cannot use if/elif/else for ex: you cannot do some thing like player_choice === "rock" and computer_choice === "scissors" ... player wins. Of course I have done this challenge and have the code but I want to see someone else do this good luck fellow pythonists. |
|
|
| Report Abuse |
|
|
|
| 23 Jan 2016 03:07 PM |
| Little mistake it's == not === damn you javascript |
|
|
| Report Abuse |
|
|
|
| 23 Jan 2016 03:14 PM |
OK Later
Funification | Was dominusawesomus | you wil cryying when obama take yur computr |Yee | ParanoidHumanoid is my trading account |
|
|
| Report Abuse |
|
|
|
| 23 Jan 2016 03:16 PM |
-- 0 is rock -- 1 is paper -- 2 is scissors function p()io.read();return math.random()<0.5;end
has user input user wins 50% of the time
no need for all that other crap :) |
|
|
| Report Abuse |
|
|
|
| 23 Jan 2016 03:17 PM |
oops ignore that
-- 0 is rock -- 1 is paper -- 2 is scissors
stuff |
|
|
| Report Abuse |
|
|
|
| 23 Jan 2016 03:25 PM |
| function p()io.read();return math.random()<0.33;end -- 1/3 lose, 1/3 tie |
|
|
| Report Abuse |
|
|
| |
|
|
| 23 Jan 2016 03:27 PM |
function p()io.read();x=math.random();return x<0.33 and 0 or x<0.66 and 1 or 2;end
that returns 0 for loss 1 for tie 2 for win |
|
|
| Report Abuse |
|
|
| |
|
|
| 23 Jan 2016 03:28 PM |
This IS the entire code Threadboy
function p()io.read();return math.random()<0.33;end p() |
|
|
| Report Abuse |
|
|
|
| 23 Jan 2016 03:29 PM |
my implementation ------------------ from random import randint
selections = ["rock", "paper", "scissors"];
def determineWinner(user, computer):
if user == computer: return "It's a tie";
winMatrix = [[False, False, True], [True,False,False],[False, True, False]];
if winMatrix[selections.index(user)][selections.index(computer)] == True: return "You won!"; return "You lost";
user_selection = input("Rock, Paper or Scissors?").lower();
while user_selection not in selections: user_selection = input("Rock, Paper or Scissors?").lower();
AI_selection = selections[randint(0,2)];
print "You: %s" %(user_selection); print "Computer: %s" %(AI_selection);
print determineWinner(user_selection, AI_selection); |
|
|
| Report Abuse |
|
|
Casualist
|
  |
| Joined: 26 Jun 2014 |
| Total Posts: 4443 |
|
|
| 23 Jan 2016 03:29 PM |
| It sounds like OP is having you guys do his programming assignment. |
|
|
| Report Abuse |
|
|
|
| 23 Jan 2016 03:30 PM |
You're bad a code golf. Even in Python, this is much more straightforward. Port function p()io.read();return math.random()<0.33;end p() to Python. |
|
|
| Report Abuse |
|
|
|
| 23 Jan 2016 03:31 PM |
"It sounds like OP is having you guys do his programming assignment." That moment when you're ninja'd with counter-evidence. |
|
|
| Report Abuse |
|
|
iPhynx
|
  |
| Joined: 25 Jul 2011 |
| Total Posts: 3271 |
|
|
| 23 Jan 2016 03:33 PM |
Put it onto GitHub. Enjoy :) gyazo.com/4208c54f9693ad84b7f43619f12892de I did it as quick as I can, yeah, it's extremely messy. Yeah, I could've used a dictionary... It works, okay?
I also made this earlier: gyazo.com/8399f1da89097089e8e18943665f9bcf
Both codes run on Python 3
--Programmer /noun/ def. A machine that is used to convert caffeine into code-- |
|
|
| Report Abuse |
|
|
|
| 23 Jan 2016 03:34 PM |
| Don't know what a code golf is but ok... |
|
|
| Report Abuse |
|
|
|
| 23 Jan 2016 03:34 PM |
takes screenshot of github link and posts that link
nice logic |
|
|
| Report Abuse |
|
|
iPhynx
|
  |
| Joined: 25 Jul 2011 |
| Total Posts: 3271 |
|
|
| 23 Jan 2016 03:35 PM |
Holy crap, yeah it's messy AF. I only beautify code if I have time. I only think logically if I have coffee. I only had tea today.
--Programmer /noun/ def. A machine that is used to convert caffeine into code-- |
|
|
| Report Abuse |
|
|
|
| 23 Jan 2016 03:36 PM |
Okay, here's some Lua code for Rock Paper Scissors.
io.read();print(math.random()<0.33)
It runs Rock Paper Scissors once and if you win, it prints "true". |
|
|
| Report Abuse |
|
|
|
| 23 Jan 2016 03:36 PM |
| phynx ur code isnt even on github |
|
|
| Report Abuse |
|
|
iPhynx
|
  |
| Joined: 25 Jul 2011 |
| Total Posts: 3271 |
|
|
| 23 Jan 2016 03:36 PM |
It's the only way, Forever. ROBLOX Admins would feast on my flesh if I posted the GitHub link... And bro, how dafaq do you not know what Code Golf is? You can pick any language and complete the task presented to you. The person with the smallest code wins (the code with the least Bytes).
--Programmer /noun/ def. A machine that is used to convert caffeine into code-- |
|
|
| Report Abuse |
|
|
iPhynx
|
  |
| Joined: 25 Jul 2011 |
| Total Posts: 3271 |
|
|
| 23 Jan 2016 03:38 PM |
@Forever - It's there, I logged out and checked. Download the .zip you dumbass.
--Programmer /noun/ def. A machine that is used to convert caffeine into code-- |
|
|
| Report Abuse |
|
|
|
| 23 Jan 2016 03:38 PM |
takes screenshot of github link and posts that link [2]
Github and Gyazo are both banned, so it doesn't really make a difference. |
|
|
| Report Abuse |
|
|
iPhynx
|
  |
| Joined: 25 Jul 2011 |
| Total Posts: 3271 |
|
|
| 23 Jan 2016 03:40 PM |
I can't believe how much I could've simplified my code and still display what the PC chose etc. Ugh, stupid me.
--Programmer /noun/ def. A machine that is used to convert caffeine into code-- |
|
|
| Report Abuse |
|
|
iPhynx
|
  |
| Joined: 25 Jul 2011 |
| Total Posts: 3271 |
|
|
| 23 Jan 2016 03:40 PM |
ROBLOX doesn't give two shts about Gyazo. It isn't banned.
--Programmer /noun/ def. A machine that is used to convert caffeine into code-- |
|
|
| Report Abuse |
|
|