generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Shortest possible rock, paper, scissors challenge:

Previous Thread :: Next Thread 
ForeverDev is not online. ForeverDev
Joined: 04 Oct 2008
Total Posts: 13300
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
verbalAKspray is not online. verbalAKspray
Joined: 09 Jul 2014
Total Posts: 23685
08 Oct 2014 02:07 PM
i have the same exact thing as you
Report Abuse
128GB is not online. 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
ForeverDev is not online. ForeverDev
Joined: 04 Oct 2008
Total Posts: 13300
08 Oct 2014 04:00 PM
@128

that doesn't loop
Report Abuse
Alyte is not online. 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 is not online. 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 is not online. 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
ForeverDev is not online. ForeverDev
Joined: 04 Oct 2008
Total Posts: 13300
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 is not online. 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 is not online. 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 is not online. 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
builderman0621 is not online. builderman0621
Joined: 13 Jul 2010
Total Posts: 1612
08 Oct 2014 09:11 PM
^
example = "example"
print example
Report Abuse
lah30303 is not online. 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
VanillaLight is not online. VanillaLight
Joined: 02 Nov 2013
Total Posts: 834
08 Oct 2014 09:34 PM
Ewww IDE ew just ew.

Bruh do you even emacs.
Report Abuse
LordMatthewII is not online. LordMatthewII
Joined: 20 Aug 2011
Total Posts: 10873
08 Oct 2014 10:00 PM
What the hell is that..?
Report Abuse
Jetta765214 is not online. Jetta765214
Joined: 22 Oct 2008
Total Posts: 1855
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
LordMatthewII is not online. LordMatthewII
Joined: 20 Aug 2011
Total Posts: 10873
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 is not online. 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
Jetta765214 is not online. Jetta765214
Joined: 22 Oct 2008
Total Posts: 1855
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
LordMatthewII is not online. LordMatthewII
Joined: 20 Aug 2011
Total Posts: 10873
09 Oct 2014 09:00 PM
Actually Nothing is random unless you consider current quantum mechanics to be true.
Report Abuse
lah30303 is not online. 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
LordMatthewII is not online. LordMatthewII
Joined: 20 Aug 2011
Total Posts: 10873
09 Oct 2014 10:35 PM
I think random as in Completely and utterly unpredictable.
Report Abuse
Ocula is not online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image