forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Random number problem

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help
View previous topic :: View next topic  
Author Message
dmonckton
Contributor
Contributor


Joined: 09 Aug 2002
Posts: 117
Location: Lewes, U.K.

PostPosted: Thu Mar 16, 2006 9:50 am    Post subject: Random number problem Reply with quote

Hi

I have written an agent that sits on the taskbar and polls a file
server at a set interval to carry out various scripted tasks. The
poll period is stored in a LOCAL ini file. In order to avoid the
agents polling in waves I have built in a randomize function of
the poll period to spread the agents out during the day. When
I tested the randomize function in the IDE it worked fine but,
when the agents out in the 'wild' try it they don't appear to very
random at all. Here are the code snippets..

Code:

:evloop
  gosub info
  gosub pollPeriod
  wait event,%%time
  %%event = @event()
  goto %%event


Code:

:pollPeriod
    rem generate a RAND No. between 1 & 3
    %a = @random(1,4)
    rem adjust poll interval according to RAND No.
    if @equal(%a,1)
        %%time = @fint(@fmul(%%poll,0.75))
        exit
    end
    if @equal(%a,2)
        %%time = %%poll
        exit
    end
    if @equal(%a,3)
        %%time = @fint(@fmul(%%poll,1.333))
        exit
    else
        rem if no RAND No. just use poll interval
        %%time = %%poll
    end     
    exit


The poll period is normally set to 300 seconds. When I
tested it in the IDE it spread the %%time out nicely but
the agents just seem to settle on 300 seconds.

Is the @random() function somehow using the clock on
the file server? I thought as the agent is running locally
it would use the local PC's clock?

Any ideas?

Thanks

David.M
Back to top
View user's profile Send private message
Dr. Dread
Professional Member
Professional Member


Joined: 03 Aug 2001
Posts: 1065
Location: Copenhagen, Denmark

PostPosted: Thu Mar 16, 2006 2:38 pm    Post subject: Reply with quote

Have you tried to seed the random function with another arbitrary value. For instance:

Code:
option decimalsep,.
random @ext(@datetime())


Greetz
Dread

_________________
~~ Alcohol and calculus don't mix... Don't drink and derive! ~~

String.DLL * advanced string processing
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group