|
| 08 Oct 2014 12:47 PM |
(using standard lua)
it must:
1) infinite loop 2) ai must pick randomly rock (r), paper (p) or scissors (s) 3) take user input for your move 4) tell you if you won, tied, or lose
this is the shortest i have it right now
::_::c=({'r','p','s'})[math.random(3)]i=io.read()print(c==i and'tie'or(c=='r'and i=='s'or c=='p'and i=='r'or c=='s'and i=='p')and'lose'or'win')goto _ |
|
|
| Report Abuse |
|
|
|
| 08 Oct 2014 02:07 PM |
| i have the same exact thing as you |
|
|
| Report Abuse |
|
|
128GB
|
  |
| Joined: 17 Apr 2014 |
| Total Posts: 8056 |
|
|
| 08 Oct 2014 03:44 PM |
| r,p,s='r','p','s'c,i=({r,p,s})[math.random(3)],io.read()print(c==i and'tie'or(c==r and i==s or c==p and i==r or c==s and i==p and 'lose' or win') |
|
|
| Report Abuse |
|
|
| |
|
Alyte
|
  |
| Joined: 24 Oct 2011 |
| Total Posts: 10090 |
|
|
| 08 Oct 2014 04:03 PM |
noobs...
I can think of a few ways to shorten OP's down to about half length or less
But that's pretty lame, I'm thinking of a better way, if I can think berry good it and it ill post it . |
|
|
| Report Abuse |
|
|
kubuto2
|
  |
| Joined: 16 Jul 2008 |
| Total Posts: 1275 |
|
|
| 08 Oct 2014 04:07 PM |
| Probably the most complicated if statement I have ever seen. |
|
|
| Report Abuse |
|
|
kubuto2
|
  |
| Joined: 16 Jul 2008 |
| Total Posts: 1275 |
|
|
| 08 Oct 2014 04:08 PM |
print*
Anyways, I'm intrigued to see if anyone can make it shorter. |
|
|
| Report Abuse |
|
|
|
| 08 Oct 2014 04:12 PM |
this is a stretch, but it gives the exact same feeling to the player
technically, if it isn't a tie, then it's a 50 / 50 chance of winning... therefore:
::_::c=({'r','p','s'})[math.random(3)]i=io.read()print(c==i and'tie'or math.random()<0.5 and'win'or'lose')goto _ |
|
|
| Report Abuse |
|
|
lah30303
|
  |
| Joined: 15 Feb 2008 |
| Total Posts: 10027 |
|
|
| 08 Oct 2014 08:22 PM |
| ...Just have the player pick a letter and have there be a 1/3 chance of winning, tieing, or losing. |
|
|
| Report Abuse |
|
|
lah30303
|
  |
| Joined: 15 Feb 2008 |
| Total Posts: 10027 |
|
|
| 08 Oct 2014 08:26 PM |
| ::_::io.read()print({"win","tie","lose"}[math.random(3)])goto_ |
|
|
| Report Abuse |
|
|
lah30303
|
  |
| Joined: 15 Feb 2008 |
| Total Posts: 10027 |
|
|
| 08 Oct 2014 08:27 PM |
| Not sure if you can remove parentheses around print, but that's just nitpicking |
|
|
| Report Abuse |
|
|
|
| 08 Oct 2014 09:11 PM |
^ example = "example" print example |
|
|
| Report Abuse |
|
|
lah30303
|
  |
| Joined: 15 Feb 2008 |
| Total Posts: 10027 |
|
|
| 08 Oct 2014 09:33 PM |
| builder, in the IDE I use (ZeroBrane Studio) parenthesis are required and that does not work. |
|
|
| Report Abuse |
|
|
|
| 08 Oct 2014 09:34 PM |
Ewww IDE ew just ew.
Bruh do you even emacs. |
|
|
| Report Abuse |
|
|
| |
|
|
| 09 Oct 2014 04:21 PM |
::_::v={'r','p','s'}c=(os.time()%3+1)i=io.read()print(i==v[c]and'tie'or(i==v[c%3+1]and'lose'or'win'))goto_
It is almost 33% shorter than OP's example, and runs without technically cheating.
Alt. of Jetta765214 |
|
|
| Report Abuse |
|
|
|
| 09 Oct 2014 04:27 PM |
local pick=math.random(1,3) if pick==1 then print('Rock') elseif pick==1 then print('Sissors') elseif pick==1 then print('Paper') end |
|
|
| Report Abuse |
|
|
lah30303
|
  |
| Joined: 15 Feb 2008 |
| Total Posts: 10027 |
|
|
| 09 Oct 2014 04:58 PM |
| depends on whether you consider os.time() to be random. |
|
|
| Report Abuse |
|
|
|
| 09 Oct 2014 08:31 PM |
True, but considering math.random isn't even random, I say its still pretty much as random as it gets, if not more random do to the human aspect.
Alt. of Jetta765214 |
|
|
| Report Abuse |
|
|
|
| 09 Oct 2014 09:00 PM |
| Actually Nothing is random unless you consider current quantum mechanics to be true. |
|
|
| Report Abuse |
|
|
lah30303
|
  |
| Joined: 15 Feb 2008 |
| Total Posts: 10027 |
|
|
| 09 Oct 2014 10:33 PM |
| There are definitions of random that don't only occur in quantum mechanics. |
|
|
| Report Abuse |
|
|
|
| 09 Oct 2014 10:35 PM |
| I think random as in Completely and utterly unpredictable. |
|
|
| Report Abuse |
|
|
Ocula
|
  |
| Joined: 02 Aug 2010 |
| Total Posts: 526 |
|
|
| 10 Oct 2014 12:16 AM |
r = math.random ::_::c=({'r','p','s'})[r(3)]i=io.read()print(c==i and'tie'or r()<0.5 and'win'or'lose')goto _
just by doing that, the statement is MUCH shorter |
|
|
| Report Abuse |
|
|