Renegade Public Forums
C&C: Renegade --> Dying since 2003™, resurrected in 2024!
Home » Tiberian Technologies / Blackhand Studios » Tiberian Technologies Forum » Commands->Get_Random_Int() is of very poor quality
Commands->Get_Random_Int() is of very poor quality [message #473077] Sun, 12 August 2012 12:59 Go to previous message
iRANian is currently offline  iRANian
Messages: 4308
Registered: April 2011
Karma:
General (4 Stars)
This function is used as the Crates plugin's random number generator, the following code is used for this plugin:

int	Rnd	= Commands->Get_Random_Int(1,101);


I get the following output with this code (output in spoilers):
	for (int i = 0; i < 100; i++)
	{
		int	Rnd	= Commands->Get_Random_Int(1,101);
		Console_Output("Rnd = %d\n", Rnd);
	}


The resulting output is:
Toggle Spoiler


The pattern is very simple, if a number is returned a few calls later a number in a range of less than 10 higher or lower will be returned (seems to average at a range of ~5 higher/lower) around 85-90% of the time.

I reported this issue to Black-Cell in 2005 if I remember correctly and one of the programmers there acknowledged Renegade's random number generator isn't that great.

The result is what you see on SSGM servers with custom crates enabled, you won't see Spy crates for an hour but after someone picks up one in close succession there will be 1-3 other Spy crates. Same with all the other crates but it's the most noticeable with this one as it has such a low probability of showing up.

The random number generator code might be time based, I haven't checked that and I doubt it as I can't see calls to time based code for any of the random number generator classes (quickly scanning over it) and I see them using rand() for stuff like team remix/rebalance.


Long time and well respected Renegade community member, programmer, modder and tester.

Scripts 4.0 private beta tester since May 2011.

My Renegade server plugins releases

[Updated on: Sun, 12 August 2012 13:10]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Crash dump
Next Topic: flame tank right click
Goto Forum:
  


Current Time: Sun Dec 22 13:24:29 MST 2024

Total time taken to generate the page: 0.00694 seconds