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
 

Question about tables!

Previous Thread :: Next Thread 
iKobi is not online. iKobi
Joined: 24 Jun 2010
Total Posts: 373
03 May 2016 06:39 PM
Lets say I have a table:

local table = {"A","B","C"}

If I set the variable x to a randomized table value, (a,b, or c)

x = table[math.random(1, 3]

and I also set the variable y to a randomized table value,

x = table[math.random(1, 3]


How can I make sure X and Y NEVER end up as the same value (a,b,c)

Report Abuse
AggressiveCatch is not online. AggressiveCatch
Joined: 17 Jul 2011
Total Posts: 5840
03 May 2016 06:42 PM
if x == y then
--set y to something else
end
Report Abuse
iKobi is not online. iKobi
Joined: 24 Jun 2010
Total Posts: 373
03 May 2016 06:44 PM
Thanks.
Report Abuse
BanTech is not online. BanTech
Joined: 31 Dec 2015
Total Posts: 886
03 May 2016 06:49 PM
local tmp=table
local ix=math.random(1,#tmp)
x=tmp[ix]
table.remove(tmp,ix)
local iy=math.random(1,#tmp)
y=tmp[iy]
Report Abuse
Flux_Capacitor is not online. Flux_Capacitor
Joined: 07 Apr 2008
Total Posts: 45720
03 May 2016 06:55 PM
tmp is not going to be a clone of the table, so you're going to end up removing from the original table.

you could always do local tmp = {unpack(tbl)} since it is an array but then doing that with a combination of a table.remove in the long run may be slower than the average time it takes to "brute-force" an unused value (although theoretically the worst case scenario for that is inf)
Report Abuse
AggressiveCatch is not online. AggressiveCatch
Joined: 17 Jul 2011
Total Posts: 5840
03 May 2016 06:57 PM
"(although theoretically the worst case scenario for that is inf)"

but that chances of that are 0.000...1%, so it's an impossible scenario
Report Abuse
BanTech is not online. BanTech
Joined: 31 Dec 2015
Total Posts: 886
03 May 2016 06:57 PM
Oops, good call! Forgot about that one.
Report Abuse
Flux_Capacitor is not online. Flux_Capacitor
Joined: 07 Apr 2008
Total Posts: 45720
03 May 2016 06:59 PM
"but that chances of that are 0.000...1%, so it's an impossible scenario"
It's improbable, impossible implies the chance is 0. Learn what impossible means. But realistically speaking, running into this problem is like winning the jackpot an infinite amount of times in a row.
Report Abuse
AggressiveCatch is not online. AggressiveCatch
Joined: 17 Jul 2011
Total Posts: 5840
03 May 2016 06:59 PM
"It's improbable, impossible implies the chance is 0. Learn what impossible means."

0.000...1 = 0

just like

.999... = 1
Report Abuse
AggressiveCatch is not online. AggressiveCatch
Joined: 17 Jul 2011
Total Posts: 5840
03 May 2016 07:00 PM
"0.000...1 = 0"

because the 1 goes at the "end", which doesn't exist in an infinite set of real numbers
Report Abuse
Flux_Capacitor is not online. Flux_Capacitor
Joined: 07 Apr 2008
Total Posts: 45720
03 May 2016 07:05 PM
No. Here, let me try to explain it (I have no idea why you're confused in the first place).

Chuck has to walk from point A to point B which is 1 KM away
He notes down how far he has left after he's walked half way from his current position to point B
His notes look like this:
.5 (1/2)
.25 (1/4)
.125(1/8)
approaching 1/inf

And so on. That's more or less what's happening here. It's not 0, it's just an infinitesimal. The probability APPROACHES 0, but it's NOT 0.
Report Abuse
Flux_Capacitor is not online. Flux_Capacitor
Joined: 07 Apr 2008
Total Posts: 45720
03 May 2016 07:10 PM
And the only way you can get 0 via multiplication is by multiplying a non 0 by 0.
In the case of the OP, call 'n' the size of the table.

The probability of selecting 'x' is 1/n
The probability of selecting 'x' again is 1/n * 1/n
And you can go on forever: 1/n * 1/n * 1/n * ...
Therefore the probability of selecting 'x' y times is 1/n^y

But you will never be multiplying by 0. Sure on a computer you can test this and it'll reach 0, but that's because there's not an infinite amount of memory for a computer to store a number.
Report Abuse
AggressiveCatch is not online. AggressiveCatch
Joined: 17 Jul 2011
Total Posts: 5840
03 May 2016 07:10 PM
???

0.000...1 = 0

what don't you understand?
Report Abuse
AggressiveCatch is not online. AggressiveCatch
Joined: 17 Jul 2011
Total Posts: 5840
03 May 2016 07:12 PM
it's only possible for something to happen a finite number of times
it's not possible (impossible) for something to happen an infinite number of times

which is a 0% chance
Report Abuse
Flux_Capacitor is not online. Flux_Capacitor
Joined: 07 Apr 2008
Total Posts: 45720
03 May 2016 07:12 PM
wow you're an idiot
"0.000...1 = 0"
You do realize I said that to clarify something, not for you to be an idiot and assume that equals 0, because it doesn't. You can't "add a number" to the end of a repeating number like that bud.
Seriously, learn basic algebra.
Report Abuse
Flux_Capacitor is not online. Flux_Capacitor
Joined: 07 Apr 2008
Total Posts: 45720
03 May 2016 07:14 PM
"it's not possible (impossible) for something to happen an infinite number of times"
Technically, no it's not (even though it's impossible realistically as you won't be able to do the event indefinitely in the first place). And if my explanation didn't make sense then give up.
I mean you might be stupid, so here's a slightly more obvious example:

I flip a coin, the chance I get heads is 1/2.
The chance I get heads twice is 1/4
The chance I get heads three times is 1/8
And so on

lim (x->inf) 1/n^x = 0, because the probability is APPROACHING 0, you can't use "infinity" as a number because IT'S NOT A NUMBER.
Report Abuse
AggressiveCatch is not online. AggressiveCatch
Joined: 17 Jul 2011
Total Posts: 5840
03 May 2016 07:14 PM
ok if we're talking about basic algebra:

x = 0.999...
10x = 9.999...

10x 9.999...
-x 0.999...
9x = 9

9x/9 = 1

if .999... = 1 then
0.00...1 also = 0 by the same principle
Report Abuse
Flux_Capacitor is not online. Flux_Capacitor
Joined: 07 Apr 2008
Total Posts: 45720
03 May 2016 07:15 PM
"if .999... = 1 then
0.00...1 also = 0 by the same principle"
What "principle" is that? How are they similar in ANY WAY?
You're seriously an idiot, give up. Consider leaving the computer science field and never doing math again.
Report Abuse
ray_1 is not online. ray_1
Joined: 18 Feb 2011
Total Posts: 464
03 May 2016 07:15 PM
technically not an infinite amount of times but an absurdly large number, so the chance is still there


Recommended username: DivergentRay_1


Report Abuse
AggressiveCatch is not online. AggressiveCatch
Joined: 17 Jul 2011
Total Posts: 5840
03 May 2016 07:17 PM
"I flip a coin, the chance I get heads is 1/2.
The chance I get heads twice is 1/4
The chance I get heads three times is 1/8
And so on

lim (x->inf) 1/n^x = 0, because the probability is APPROACHING 0, you can't use "infinity" as a number because IT'S NOT A NUMBER."

it will reach 0

same with the other thing about the dude walking 1k

according to ur logic, the dude can never walk 1k because he always has to walk half of half of half etc.

but he can walk 1k

so ur logic doesn't make sense
Report Abuse
AggressiveCatch is not online. AggressiveCatch
Joined: 17 Jul 2011
Total Posts: 5840
03 May 2016 07:19 PM
"if .999... = 1 then
0.00...1 also = 0 by the same principle"
What "principle" is that? How are they similar in ANY WAY?"

are you stupid?

would you agree that:

1-0.999... = 0.000...1

I already proved that 0.999... = 1

so 1-1 = 0

so 0= 0.000...1
Report Abuse
Flux_Capacitor is not online. Flux_Capacitor
Joined: 07 Apr 2008
Total Posts: 45720
03 May 2016 07:19 PM
'it will reach 0'
You're stupid, go graph 1/x on your calculator.

'according to ur logic, the dude can never walk 1k because he always has to walk half of half of half etc.'
Except that it was a theoretical story. Mathematics doesn't model the universe exactly, only approximates it. There is a 'smallest size' in the universe and it's not 0.
Report Abuse
Flux_Capacitor is not online. Flux_Capacitor
Joined: 07 Apr 2008
Total Posts: 45720
03 May 2016 07:20 PM
"would you agree that:
1-0.999... = 0.000...1"
No, I would not agree that. I agree "1 - 0.999..." is 0.
You can't "add a 1" to the end.
Report Abuse
Dr01d3k4 is not online. Dr01d3k4
Joined: 11 Oct 2007
Total Posts: 17916
03 May 2016 07:20 PM
1 - 0.999... ≠ 0.000...1
1 - 0.999... = 0
Report Abuse
AggressiveCatch is not online. AggressiveCatch
Joined: 17 Jul 2011
Total Posts: 5840
03 May 2016 07:21 PM
"'it will reach 0'
You're stupid, go graph 1/x on your calculator."

you're stupid, you can only reach a finite number on your calculator, so you can never see the point where it meets the y axis
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 2Go to page: [1], 2 Next
 
 
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