ACS: random() alternatives?
ACS: random() alternatives?
I think we all know that the RNG is complete shit. What are the accepted tricks to try and get more randomness from a random(x,y) ACS call?
			
									
									Code: Select all
[15:53:14] balrog: one day, the original mm8bdm devteam from mfggu and i will meet in valhalla and we will be friendsCode: Select all
<ijon>well fuk
<ijon>guess I gotta suck dicks nowCode: Select all
(18:13:17)<Mayrine>i dont have to learnt anything about ACS- Combinebobnt
 - Retired Staff / Community Team Member
 - Posts: 1906
 - Joined: Mon Jun 04, 2012 3:37 am
 - Location: Earth
 - Contact:
 
RE: ACS: random() alternatives?
Duel32 does it based on the game time passed.
			
									
									
						- 
				Catastrophe
 - Retired Staff / Community Team Member
 - Posts: 2571
 - Joined: Sat Jun 02, 2012 2:44 am
 
RE: ACS: random() alternatives?
The above wouldn't work if you're executing a script at a specific time.
			
									
									
						- 
				Ijon Tichy
 - Frequent Poster Miles card holder
 - Posts: 901
 - Joined: Mon Jun 04, 2012 5:07 am
 
RE: ACS: random() alternatives?
The RNG is perfectly fine; it's just that its seed is shit. Of course we can't read from /dev/urandom or whatever the Winderps equivalent is, so no luck there.
Might want to pull in a bunch of CVars, throw some Random() number number in there, and run Random that many times as a pseudo-seed. Just an idea.
			
									
									
						Might want to pull in a bunch of CVars, throw some Random() number number in there, and run Random that many times as a pseudo-seed. Just an idea.
- Torr Samaho
 - Lead Developer
 - Posts: 1543
 - Joined: Fri May 25, 2012 6:03 pm
 - Location: Germany
 
RE: ACS: random() alternatives?
Are you referring to this issue?Balrog wrote: I think we all know that the RNG is complete shit.
RE: ACS: random() alternatives?
Well you could do a hell load of random() and then find their average or median just an idea.
			
									
									[][][][][][][][][][][][][][][]
Nothing to see here
[][][][][][][][][][][][][][][]
						Nothing to see here
[][][][][][][][][][][][][][][]
RE: ACS: random() alternatives?
Currently two calls in an OPEN script a random(1,14) call and a random(1000,1031) call 5 seconds later. (I've been meaning to make it a 64-player deal, but I've also got a clunky old inventory-based death manager that I don't want to strain any further) The second call gets repeated until it comes up with the TID of a extant player. The solution I'm thinking of based on Ijon's response is running random(1,500) random(1,dmflags%10+1) times, but I'm open to suggestions.Qent wrote: What are you using it for?
Maybe....Torr Samaho wrote:Are you referring to this issue?Balrog wrote: I think we all know that the RNG is complete shit.
					Last edited by Balrog on Tue Feb 19, 2013 1:18 am, edited 1 time in total.
									
			
									Code: Select all
[15:53:14] balrog: one day, the original mm8bdm devteam from mfggu and i will meet in valhalla and we will be friendsCode: Select all
<ijon>well fuk
<ijon>guess I gotta suck dicks nowCode: Select all
(18:13:17)<Mayrine>i dont have to learnt anything about ACSRE: ACS: random() alternatives?
Assuming timer() is in Zandronum, can't you just do
Of course it would still be the same if you call it in OPEN I assume, as no time has elapsed (it's just random(x, y) then.)
If you're working with a server, you could mess with variables, and use them as a random seed, something like
EDIT: You might have to check which one is bigger in 999, I dunno what would happen with like random(2, 1)
			
													Code: Select all
function int newRandom(int x, int y)
	return random(timer() + x, timer() + y) - timer();If you're working with a server, you could mess with variables, and use them as a random seed, something like
Code: Select all
function int timerRandom(int x, int y)
	return random(timer() + x, timer() + y) - timer();
script 999 UNLOADING
	ConsoleCommand(StrParam(s:"set sv_oldseed ", d:timerRandom(timer(), GetCvar("sv_oldseed"))));
function int newRandom(int x, int y)
	return random(GetCvar("sv_oldseed") + x, GetCvar("sv_oldseed") + y) - GetCvar("sv_oldseed");
script 1 (void) // your script
{
	// Blah
	myRandom = newRandom(0, 31);
}
					Last edited by Llewellyn on Tue Feb 19, 2013 3:39 am, edited 1 time in total.
									
			
									
						- Torr Samaho
 - Lead Developer
 - Posts: 1543
 - Joined: Fri May 25, 2012 6:03 pm
 - Location: Germany
 
RE: ACS: random() alternatives?
You can easily tell whether this is your problem or not as the issue described in the ticket only affects how the RNG is initialized after a map change.Balrog wrote:Maybe....Torr Samaho wrote: Are you referring to this issue?
So far you just complained about the randomness of the function without indicating what exactly the problem you have with it is. Would you mind elaborating?
RE: ACS: random() alternatives?
The problem that I'm having is that certain results are coming up very often, while others aren't showing up at all. Interestingly, the one that almost never shows up - 14 on the random(1,14) call - shows up much more often in the "prepare to fight" LMS pre-game. Also, here's the script snippets that are relevant:
Yes, I made some mistakes in the previous posts. Sorry about that.
			
													Code: Select all
Script 1 (void)
{
boss = random(1,12);
If(PlayerCount() >= 3){
boss = random(1,14);
}
terminate;
}
Script 2 OPEN
{
if(Timer()>0){
terminate;
}
ACS_Execute(1,0);
Delay(35*5);
ACS_Execute(3,0);
}
Script 3 (void)
{
BossPlayer= random(1000,1031);
if(LastBossPlayer == BossPlayer){
Delay(2);
restart;
}
if(LastBoss == boss){
ACS_Execute(1,0);
Delay(1);
restart;
}
/* Stuff here makes decisions on what to do and who to do it to based on the values of boss and BossPlayer, sets the values of LastBoss and LastBossPlayer to equal boss and BossPlayer, and then terminates if a sanity check shows that it was successful */
restart;
}
					Last edited by Balrog on Wed Feb 20, 2013 4:53 pm, edited 1 time in total.
									
			
									Code: Select all
[15:53:14] balrog: one day, the original mm8bdm devteam from mfggu and i will meet in valhalla and we will be friendsCode: Select all
<ijon>well fuk
<ijon>guess I gotta suck dicks nowCode: Select all
(18:13:17)<Mayrine>i dont have to learnt anything about ACSRE: ACS: random() alternatives?
Hangman used to suffer from something related to random online- out of 500 words, it'd consistently use only ~6 of them every round.
			
									
									
						