SRL Archive - Senior Scripts and Snippets

AntiLag Randoms


Smartzkid

2007-09-01 17:34:58

This is an idea I came up with for one of my SMART scripts to reduce lag, and it worked well enough that I put it into a script that I plan to release soon. I told Boreas about it, and he told me to post it here, so it is.

procedure Randoms;
//variables (all integers):
//RandomProcTime: the time it takes for the procedure to finish
//[external]
//RandomCheckTime: the time since the procedure was last called
//RandomBenchTime: the average time taken to finish the procedure
var
RandomProcTime: integer;
begin
if(TimeFromMark(RandomCheckTime) < Round(RandomBenchTime * 1.1))then
Exit;
MarkTime(RandomProcTime);
MarkTime(RandomCheckTime);
FindNormalRandoms;
RandomBenchTime := ((RandomBenchTime * 7) + TimeFromMark(RandomProcTime)) / 8; //Calculate the new average time
SaveSetting('PowerKut', 'AntiLag', IntToStr(RandomBenchTime)); //So it can be retrieved at the next run
AddToReport(IntToStr(RandomBenchTime)); //Debug
end;

nielsie95

2007-09-02 05:20:15

You can also speed up FindNormalRandoms itself.. :)

Regular FindNormalRandoms: 140
FindNormalRandoms | 1 FindTalk: 125
FindNormalRandoms | wait mod 2: 93
FindNormalRandoms | 1 FindTalk | wait mod 2: 94
FindNormalRandoms | 1 FindTalk | no wait: 63
*All in ms.

In this test I took out respond..

Wizzup?

2007-09-02 05:25:33

Smartz, what about just timed randomfinding, like in my VEM.

Smartzkid

2007-09-02 13:56:41

Yours calls the antirandoms at set intervals, mine adjusts the interval.

I didn't want to use set intervals because they keep the antirandoms from responding as quickly on good computers, and still might lag on bad computers.

But yeah, they're essentially the same.