Author |
Message |
Maverick

Age:40 Gender: Joined: Feb 26 2005 Posts: 1521 Location: The Netherlands Offline
|
Posted: Wed Aug 17, 2005 3:24 am Post subject: |
 |
|
|
|
Ok, how to get a Mervbot plugin to call a function every 101 ms ?
I guess you would have to create a timer (and a thread?) to do that, can someone give me an example of that? _________________
|
|
Back to top |
|
 |
Bak ?ls -s 0 in

Age:26 Gender: Joined: Jun 11 2004 Posts: 1826 Location: USA Offline
|
|
Back to top |
|
 |
Maverick

Age:40 Gender: Joined: Feb 26 2005 Posts: 1521 Location: The Netherlands Offline
|
Posted: Thu Aug 18, 2005 3:37 pm Post subject: |
 |
|
|
|
Guess that is another solution to the problem, but it would be making mervbot custom then. Hmmm, custom mervbot for my plugin  |
|
Back to top |
|
 |
xor eax Novice
Joined: Jun 01 2005 Posts: 93 Location: Spain Offline
|
|
Back to top |
|
 |
Maverick

Age:40 Gender: Joined: Feb 26 2005 Posts: 1521 Location: The Netherlands Offline
|
Posted: Fri Aug 19, 2005 6:24 am Post subject: |
 |
|
|
|
Thanks I will try that.
 |
|
Back to top |
|
 |
CypherJF I gargle nitroglycerin

Gender: Joined: Aug 14 2003 Posts: 2582 Location: USA Offline
|
Posted: Fri Aug 19, 2005 8:06 am Post subject: |
 |
|
|
|
Submit any core changes to catid to merge into the main build. I saw SOS posted his version of Merv, but doesn't it need .NET? _________________ Performance is often the art of cheating carefully. - James Gosling |
|
Back to top |
|
 |
Maverick

Age:40 Gender: Joined: Feb 26 2005 Posts: 1521 Location: The Netherlands Offline
|
Posted: Fri Aug 19, 2005 10:08 am Post subject: |
 |
|
|
|
xor eax, what should be the name of the CALLBACK TimerProc() function be if I want it to be part of the botInfo:: class ? Or isn't that possible? |
|
Back to top |
|
 |
Smong Server Help Squatter

Joined: 1043048991 Posts: 0x91E Offline
|
|
Back to top |
|
 |
Cyan~Fire I'll count you!

Age:37 Gender: Joined: Jul 14 2003 Posts: 4608 Location: A Dream Offline
|
Posted: Fri Aug 19, 2005 3:46 pm Post subject: |
 |
|
|
|
I'm curious. Without a message loop, how exactly does the timer notification get to your code? A separate thread? In that case, wouldn't you have to mess around with mutex's? _________________ This help is informational only. No representation is made or warranty given as to its content. User assumes all risk of use. Cyan~Fire assumes no responsibility for any loss or delay resulting from such use.
Wise men STILL seek Him. |
|
Back to top |
|
 |
xor eax Novice
Joined: Jun 01 2005 Posts: 93 Location: Spain Offline
|
Posted: Fri Aug 19, 2005 5:11 pm Post subject: |
 |
|
|
|
Maverick wrote: | what should be the name of the CALLBACK TimerProc() function be if I want it to be part of the botInfo:: class ? Or isn't that possible? |
TimerProc does not need to be a class member, but Smong and others know MERV and C++ much better than me, lets see what the experts say...
Cyan~Fire wrote: | Without a message loop, how exactly does the timer notification get to your code? |
This is taken from the Win32API help file, SetTimer function:
"When you specify a TimerProc callback function, the DispatchMessage function simply calls the callback function instead of the window procedure. Therefore, you need to dispatch messages in the calling thread, even when you use TimerProc instead of processing WM_TIMER."
One way or the other it needs a message loop. |
|
Back to top |
|
 |
Maverick

Age:40 Gender: Joined: Feb 26 2005 Posts: 1521 Location: The Netherlands Offline
|
Posted: Fri Aug 19, 2005 5:15 pm Post subject: |
 |
|
|
|
Smong, how do I make that extra parameter 'this' use with the code xor eax posted?
Cyan~Fire thats more or less the problem I am having (was said on another forum about settimer and non-static functions) |
|
Back to top |
|
 |
Mr Ekted Movie Geek

Gender: Joined: Feb 09 2004 Posts: 1379 Offline
|
Posted: Fri Aug 19, 2005 5:25 pm Post subject: |
 |
|
|
|
Using Win API SetTimer() to handle bot timers is not good. _________________ 4,691 irradiated haggis! |
|
Back to top |
|
 |
D1st0rt Miss Directed Wannabe

Age:37 Gender: Joined: Aug 31 2003 Posts: 2247 Location: Blacksburg, VA Offline
|
Posted: Fri Aug 19, 2005 5:29 pm Post subject: |
 |
|
|
|
Does pbot have separate timers or just really fast ticking? _________________
 |
|
Back to top |
|
 |
Cyan~Fire I'll count you!

Age:37 Gender: Joined: Jul 14 2003 Posts: 4608 Location: A Dream Offline
|
Posted: Fri Aug 19, 2005 9:34 pm Post subject: |
 |
|
|
|
He said once before the pbot defines a timer interface for its plugins. This is something I will add to MERVBot, if I ever finish. |
|
Back to top |
|
 |
xsp0rtsfanx Seasoned Helper

Age:36 Gender: Joined: Dec 27 2004 Posts: 168 Location: California Offline
|
Posted: Sat Aug 20, 2005 12:38 am Post subject: |
 |
|
|
|
i'm glad my topic started helping out with something for mervbot although i got lost when people starting posting code lol |
|
Back to top |
|
 |
Mr Ekted Movie Geek

Gender: Joined: Feb 09 2004 Posts: 1379 Offline
|
Posted: Sat Aug 20, 2005 2:32 am Post subject: |
 |
|
|
|
Pbot has a 100ms tick event and a programmable timer event (with 100ms granularity). Even if there are 20 bots, each with 20 modules, each with 20 timers going (8000!), there's no overhead. I keep timers in a linked list sorted by trigger time, and only have to check the top one. Try calling Win API SetTimer() 8000 times. |
|
Back to top |
|
 |
Cerium Server Help Squatter

Age:42 Gender: Joined: Mar 05 2005 Posts: 807 Location: I will stab you. Offline
|
Posted: Sat Aug 20, 2005 6:19 am Post subject: |
 |
|
|
|
Single threaded? _________________ There are 7 user(s) ignoring me right now. |
|
Back to top |
|
 |
CypherJF I gargle nitroglycerin

Gender: Joined: Aug 14 2003 Posts: 2582 Location: USA Offline
|
Posted: Sat Aug 20, 2005 7:17 am Post subject: |
 |
|
|
|
Doubtful. |
|
Back to top |
|
 |
Mr Ekted Movie Geek

Gender: Joined: Feb 09 2004 Posts: 1379 Offline
|
Posted: Sat Aug 20, 2005 9:57 am Post subject: |
 |
|
|
|
Each bot is a single thread. Each thread manages its own timer list in the core. |
|
Back to top |
|
 |
Maverick

Age:40 Gender: Joined: Feb 26 2005 Posts: 1521 Location: The Netherlands Offline
|
Posted: Sat Aug 20, 2005 10:48 am Post subject: |
 |
|
|
|
Whats the solution for mervbot then?
Mervbot has a tick event, which goes once every second. for the rest nothing that can be really used to spec areas on a map reliable.
I need something like a timer to make function being called every 101 ms. But with a timer I have problems with non-static functions etc.
Is there a solution to making timers work in Mervbot or do I have to make a custom mervbot to have the tick event go every 101 ms?
(Can a mod split this topic into noisySpectator entitled topic please?) |
|
Back to top |
|
 |
xor eax Novice
Joined: Jun 01 2005 Posts: 93 Location: Spain Offline
|
Posted: Sat Aug 20, 2005 11:03 am Post subject: |
 |
|
|
|
So using 1 timer is not good because 8000 timers are an overhead?
Who is talking about calling SetTimer 8000 times? Not Maverick, not Smong, not me.
All I'm saying is that what Maverick wants can be done using SetTimer. And I haven't heard any good argument of yours against that.
Do you think a single timer per bot supose a significant overhead?
How is pbot handling the timer event? Is it using a timer or a... wheelchair?
How you're fabulous theory applies to Maverick's needs?
(and yes, Cerium, it can be single threaded, it simply does not depend on the thread model) |
|
Back to top |
|
 |
Mr Ekted Movie Geek

Gender: Joined: Feb 09 2004 Posts: 1379 Offline
|
Posted: Sat Aug 20, 2005 11:17 am Post subject: |
 |
|
|
|
Obviously my example was hyperbole. My point is that when coding, you consider scaleability. Don't do a "one time hack" that will end up being the foundation of something much more widely used.
Also, why exactly 101ms? Do you realize that, depending on the operating system, the resolution of the system timers could be as high as 16ms? Under Windows, if you are running in a worker thread (ie not a message loop), you can potentially use the multimedia timer or the high-res timer to get 1ms or even 1us accuracy. However, polling those timers has its own overhead. |
|
Back to top |
|
 |
Maverick

Age:40 Gender: Joined: Feb 26 2005 Posts: 1521 Location: The Netherlands Offline
|
Posted: Sat Aug 20, 2005 5:29 pm Post subject: |
 |
|
|
|
I don't care it has to be 101 ms, at least faster then the current EVENT_Tick of Mervbot.
I guess I am going to continue building my bot based on noisyspectator :/ |
|
Back to top |
|
 |
Guest
Offline
|
Posted: Sun Aug 21, 2005 12:00 pm Post subject: |
 |
|
|
|
Mav, you want the bot to spec players one by one, if I understood well.
And I guess 101 msecs is the minimum time you must wait to assure that 1 position packet at least will be received from each player.
You want a non-static function to be triggered every X milliseconds... Why don't you call the non-static function from the TimerProc function?
Anyway, I think it can be done without a timer:
Why don't you make it so when a position packet arrives from the expected player then the bot switches to next player?
-You put the bot to spec the next player in list.
-When its correspondent position packet arrives the bot switches to next player.
-If a player goes to spec or leave the arena it is removed from the list of players being speced by the bot. And if the bot was specing him it switches to next player. When a player enter it is added to the list... etc.
Well... sorry Mav, I'm trying to help but maybe is better not to try it if I can't do it properly... |
|
Back to top |
|
 |
xor eax Novice
Joined: Jun 01 2005 Posts: 93 Location: Spain Offline
|
Posted: Sun Aug 21, 2005 12:02 pm Post subject: |
 |
|
|
|
the guest is me |
|
Back to top |
|
 |
|