Hard Light Productions Forums

Modding, Mission Design, and Coding => The FRED Workshop => Topic started by: FUBAR-BDHR on April 07, 2008, 01:21:57 am

Title: Rand-multiple not being random?
Post by: FUBAR-BDHR on April 07, 2008, 01:21:57 am
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.
Title: Re: Rand-multiple not being random?
Post by: karajorma on April 07, 2008, 02:26:10 am
Have you used rand_multiple or rand with 3 arguments anywhere?
Title: Re: Rand-multiple not being random?
Post by: FUBAR-BDHR on April 07, 2008, 02:32:08 am
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. 
Title: Re: Rand-multiple not being random?
Post by: karajorma on April 07, 2008, 03:02:29 am
Hmmm. The third argument is a seed for the random function. If you had it, then it would explain a lot.
Title: Re: Rand-multiple not being random?
Post by: FUBAR-BDHR on April 07, 2008, 12:50:14 pm
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]
Title: Re: Rand-multiple not being random?
Post by: FUBAR-BDHR on April 07, 2008, 09:41:20 pm
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. 
Title: Re: Rand-multiple not being random?
Post by: karajorma on April 08, 2008, 01:39:55 pm
Coincidence would be my bet. It was the bane of my existence last time I fiddled with random events.
Title: Re: Rand-multiple not being random?
Post by: FUBAR-BDHR on April 08, 2008, 02:18:31 pm
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.