Author Topic: Rand-multiple not being random?  (Read 2157 times)

0 Members and 1 Guest are viewing this topic.

Offline FUBAR-BDHR

  • Self-Propelled Trouble Magnet
  • 212
  • Master Drunk
    • 165th Beer Drinking Hell Raisers
Rand-multiple not being random?
I'm using rand-multiple for a few different things in a mission.  For one thing I have using a range of 1-7 and it is working OK but not great.  It does hit all the values but likes to hit certain ones (7 especially) over and over again.  For the other I'm using a range of 10-30.  I have 7 events that each evaluate the rand-multi twice.  Every one of them hit 11 the first time and all but 2 hit 13 the second time.  I paused the mission twice which might have thrown the other 2 off.  I played the mission twice and 11 the first time seem to be consistent.  I didn't check the second value the other time through since I had the wrong event referred to in an another event and I ended the mission early to fix it. 

This is the formula I am using that keeps getting the 11.

When
...............
--> >
--> mission time
----> +
------> delay(0) (stored mission time)
------> rand-multiple
--------> 10
--------> 30
...............

Actually I guess it's evaluating to 10 and 12 since I was comparing time values in the F4 log and it's greater than. 

Just tried with the range set to 1-30 and all calls evaluated to 1 and 3 instead of 10 and 12.
« Last Edit: April 07, 2008, 02:24:20 am by FUBAR-BDHR »
No-one ever listens to Zathras. Quite mad, they say. It is good that Zathras does not mind. He's even grown to like it. Oh yes. -Zathras

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: Rand-multiple not being random?
Have you used rand_multiple or rand with 3 arguments anywhere?
Karajorma's Freespace FAQ. It's almost like asking me yourself.

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

 

Offline FUBAR-BDHR

  • Self-Propelled Trouble Magnet
  • 212
  • Master Drunk
    • 165th Beer Drinking Hell Raisers
Re: Rand-multiple not being random?
Nope.  I'll double check to make sure FRED didn't decide to pop one in there but I've been through the code about 20 times now looking for anything wrong. 

Double checked and no third argument on any of them.  They are all rand-multiple. 

Just tried the 3.6.10 build and it did the same thing. 
« Last Edit: April 07, 2008, 02:53:02 am by FUBAR-BDHR »
No-one ever listens to Zathras. Quite mad, they say. It is good that Zathras does not mind. He's even grown to like it. Oh yes. -Zathras

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: Rand-multiple not being random?
Hmmm. The third argument is a seed for the random function. If you had it, then it would explain a lot.
Karajorma's Freespace FAQ. It's almost like asking me yourself.

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

 

Offline FUBAR-BDHR

  • Self-Propelled Trouble Magnet
  • 212
  • Master Drunk
    • 165th Beer Drinking Hell Raisers
Re: Rand-multiple not being random?
The only other thing I can think of that could be causing the problem is something strange going on with percent-ships-destroyed.   The event is repeating and true if one of two things happens.  The random time delay or percent-ships-destroyed 100.  Now the arrival of the wing is base on the event being true.  Maybe the wing arrival being base on an event that evaluates the wing is causing some kind of quark.  Don't have time to test that theory until tonight. 

Attaching mission.  It's a single player version of a multi TBP mission.   

[attachment deleted by ninja]
No-one ever listens to Zathras. Quite mad, they say. It is good that Zathras does not mind. He's even grown to like it. Oh yes. -Zathras

 

Offline FUBAR-BDHR

  • Self-Propelled Trouble Magnet
  • 212
  • Master Drunk
    • 165th Beer Drinking Hell Raisers
Re: Rand-multiple not being random?
OK I removed the rand-multiple from the 7 events and added it to the one that has the other rand-multiple.  It does produce random results now but still returned 10 the first time which is either a major coincidence or some kind of quark.   I'm even on a different computer now. 
No-one ever listens to Zathras. Quite mad, they say. It is good that Zathras does not mind. He's even grown to like it. Oh yes. -Zathras

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: Rand-multiple not being random?
Coincidence would be my bet. It was the bane of my existence last time I fiddled with random events.
Karajorma's Freespace FAQ. It's almost like asking me yourself.

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

  

Offline FUBAR-BDHR

  • Self-Propelled Trouble Magnet
  • 212
  • Master Drunk
    • 165th Beer Drinking Hell Raisers
Re: Rand-multiple not being random?
Never did get around to trying that again last night.  Even if it does always evaluate the same the first time I can just have it loop an extra time to get by that.

I'm thinking for future use I might just make an every-time event that does all the rand-multi evaluations and stores them to temporary variables.  Then I just use the temporary variable where I would have used the rand-multi.  Should work around the first value coming up the same (if it does) and make it even more random since not only will the random function be used but it will evaluate a random number of times between uses. 
No-one ever listens to Zathras. Quite mad, they say. It is good that Zathras does not mind. He's even grown to like it. Oh yes. -Zathras