Author Topic: rand & rand-multiple  (Read 2541 times)

0 Members and 1 Guest are viewing this topic.

Offline IPAndrews

  • Disgruntled Customer
  • 212
  • This site stole my work
rand & rand-multiple
In which build was the "rand" SEXP first change and in which subsequent build was "rand-multiple" introduced to do what "rand" used to do?
Be warned: This site's admins stole 100s of hours of my work. They will do it to you.

 

Offline phreak

  • Gun Phreak
  • 211
  • -1
rand-multiple was introduced on 1/26/05

rand was "fixed" on 12/23/02
Offically approved by Ebola Virus Man :wtf:
phreakscp - gtalk
phreak317#7583 - discord

 

Offline Goober5000

  • HLP Loremaster
  • Moderator
  • 214
    • Goober5000 Productions
Quote
Originally posted by PhReAk
rand was "fixed" on 12/23/02
Actually, that was when rand was "broken".  It was restored to its original code when rand-multiple was introduced.

 

Offline phreak

  • Gun Phreak
  • 211
  • -1
hence the quotes.

Code: [Select]
* Revision 2.14  2002/12/23 05:41:08  Goober5000
 * Bah - Andsager is a moron. :) I see no reason why rand shouldn't work
 * multiple times.  It's been fixed thus.
 * --Goober5000
Offically approved by Ebola Virus Man :wtf:
phreakscp - gtalk
phreak317#7583 - discord

 

Offline Goober5000

  • HLP Loremaster
  • Moderator
  • 214
    • Goober5000 Productions
Oh okay, I gotcha.

I deeply regret calling a :v: programmer a moron. :(

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Was there ever anyything that the fix to rand ever broke?

It's not an often used SEXP anyway and you have to be using it in a repeating event to notice anything that Goober ever did to it.
Karajorma's Freespace FAQ. It's almost like asking me yourself.

[ Diaspora ] - [ Seeds Of Rebellion ] - [ Mind Games ]

 

Offline Goober5000

  • HLP Loremaster
  • Moderator
  • 214
    • Goober5000 Productions
It's more subtle than that, and it doesn't require a repeating event.  Suppose you have an event that combines both "rand" and another sexp using "and".  The code must continually evaluate the two conditions until both are true.

The original implementation of "rand" had the sexp short-circuit its evaluation by replacing itself with the chosen random value.  In effect, the random number was only picked once, and it remained consistent for every evaluation of the sexp.  My original change caused "rand" to pick a new random number every time the sexp was evaluated.  (This is what "rand-multiple" does now.)

I can't really think of an example to illustrate the result of this, but you can think of it as a sort of quantum uncertainty.  The value of "rand" is unknown until it is locked in place when both halves of the "and" sexp become true at the same time.  I forget the exact situation which clued me in to this difference, but it definitely exists as evidenced by the fact that TBP noticed it. :)

As an aside, "rand-multiple" is probably not the best name for the new sexp but it was the best I could think of at the time.  Do you have any suggestions?  "Quantum-rand", maybe? ;)

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
I see. What happens when you use Rand with every-time though? I imagine that in that case it would re-evaluate itself right?
Karajorma's Freespace FAQ. It's almost like asking me yourself.

[ Diaspora ] - [ Seeds Of Rebellion ] - [ Mind Games ]

 

Offline Goober5000

  • HLP Loremaster
  • Moderator
  • 214
    • Goober5000 Productions
Probably.

That might be a better way of illustrating the difference between when and every-time than with key-pressed. :)

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Yeah. I'll try that out in a little bit.
Karajorma's Freespace FAQ. It's almost like asking me yourself.

[ Diaspora ] - [ Seeds Of Rebellion ] - [ Mind Games ]

 

Offline Roanoke

  • 210
*head starts spinning*

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
It's pretty simple. If you really want an explaination I'm happy to type one up for you :)

What's confusing you?
Karajorma's Freespace FAQ. It's almost like asking me yourself.

[ Diaspora ] - [ Seeds Of Rebellion ] - [ Mind Games ]

 

Offline Roanoke

  • 210
Nah, don't worry about it. ;)

  

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Fair enough. I'll be adding explainations for this sort of thing to my FAQ sooner or later anyway :D
Karajorma's Freespace FAQ. It's almost like asking me yourself.

[ Diaspora ] - [ Seeds Of Rebellion ] - [ Mind Games ]