Server Help

Bot Questions - Making bot wait for 10 seconds?

Anonymous - Sat Jan 22, 2005 5:21 am
Post subject: Making bot wait for 10 seconds?
How do I make a bot wait for 10 seconds? I tried C++'s Sleep(1000); but that didn't work. Can anyone help?
Solo Ace - Sat Jan 22, 2005 5:47 am
Post subject:
That'd be Sleep(10000), but you should use the ticker (in MERVbot) instead of Sleep().
D1st0rt - Sat Jan 22, 2005 10:14 am
Post subject:
I'm sure somebody will correct me, but I believe sleep makes the current thread inactive for the specified amount of time. This might mean you don't send or receive packets (depending on how merv is threaded, I haven't looked), so I would go with Solo and use EVENT_Tick.
Mr Ekted - Sat Jan 22, 2005 5:40 pm
Post subject:
Definitely do not use Sleep(). But also I would not use tick events. This requires polling. If you have 10 bots with 10 modules each, that's 100 polls per tick. What a waste of CPU.
Cyan~Fire - Sat Jan 22, 2005 11:22 pm
Post subject:
MERV sends an EVENT_Tick every second anyway.
Bak - Sun Jan 23, 2005 12:29 am
Post subject:
he's not running 10 bots with 10 copies of the exact module. He's running one bot with one version of the module -> 1 poll per tick
Mr Ekted - Sun Jan 23, 2005 2:23 am
Post subject:
Bak wrote:
he's not running 10 bots with 10 copies of the exact module. He's running one bot with one version of the module -> 1 poll per tick


I was being hypothetical. The point is: the proper place for time checking is in the core, with events to notify modules. Using this method, the core can poll a single interval per tick and notify modules accordingly.
50% Packetloss - Sun Jan 23, 2005 3:28 am
Post subject:
I found powerbot's timer methods much handier that mervbots. But yah, in mervbot you need to use event_tick, its called once every second (or close to it depending on how often control is returned to the core).
So a posibility is to have a variable in event_tick that increments each time the event is run and keep track of the time that way. Use of the sleep() function will cause your bot to lag out.
Mr Ekted - Sun Jan 23, 2005 4:53 am
Post subject:
You can't really rely on events coming at any particular rate. Timing 10 events that are supposed to occur every second will not guarantee a 10 second interval. If you don't need that kind of precision, then I guess it's fine, but it still means polling of a kind (checking your own counter every tick).
Underlord - Sun Jan 23, 2005 7:43 am
Post subject:
Code: Show/Hide

// spawn.h

        class botInfo
        {
        int countdown[1]; 

                public:
                botInfo(CALL_HANDLE given)
                {
                countdown[0] = 10;   // initially starts at 10 seconds

//spawn.cpp

            case EVENT_Tick:   // called once a second
            {
                for (int i = 0; i < 1; ++i)
                    --countdown[i];

                if (countdown[0] == 0) // 10 seconds have passed
                {
                   countdown[0] = 10;  // reset timer
                   // insert code that happens every 10 seconds here
                }

Mr Ekted - Sun Jan 23, 2005 2:33 pm
Post subject:
Exactly what I was saying NOT to do.
D1st0rt - Sun Jan 23, 2005 2:35 pm
Post subject:
thats how merv does it, if you want people to do it right, you should just give us all a copy of powerbot biggrin.gif
Solo Ace - Sun Jan 23, 2005 2:36 pm
Post subject:
Instead of saying what not to do, could you tell him then how to do it right?
Cyan~Fire - Sun Jan 23, 2005 2:58 pm
Post subject:
@Solo:
Ekted wrote:
The point is: the proper place for time checking is in the core, with events to notify modules. Using this method, the core can poll a single interval per tick and notify modules accordingly.


I'm not sure if I understand you correctly, Ekted, but isn't that what MERV does?
Solo Ace - Sun Jan 23, 2005 3:05 pm
Post subject:
Meh, sorry, I thought I read that part of this thread already. sa_tongue.gif

I think he means the core should do the time checking and notify the plugins when it's supposed to, instead of notifying the plugins each tick to let them run a timer seperately.
Mr Ekted - Sun Jan 23, 2005 7:54 pm
Post subject:
Yes. Powerbot has a SetTimer() call. The core manages all the timers sorted by time, so it only needs to check the shortest one. Even if there are 100 different timers going for all the modules, there's only ever 1 poll unless a bunch of timers trigger at the same time. Merv could do this.
D1st0rt - Sun Jan 23, 2005 7:57 pm
Post subject:
like I said, hook us up and put an end to such nonsense biggrin.gif
Cyan~Fire - Sun Jan 23, 2005 8:16 pm
Post subject:
Ekted wrote:
Merv could do this.

But Catid is depressed about (read: has given up on?) MERV. icon_sad.gif
Solo Ace - Sun Jan 23, 2005 8:38 pm
Post subject:
Uh, what? Catid's stopping with Merv?
Cyan~Fire - Sun Jan 23, 2005 10:39 pm
Post subject:
No, just every time I've talked to him, he's said that he hates MERV. That plus the fact that he hasn't replied to an email i sent him about a source code improvement and no new updates makes me think he's not going to actively develop it anymore. Also, notice that all the recent changes in Changelog.txt are other people's/bugfixes.
50% Packetloss - Mon Jan 24, 2005 6:18 am
Post subject:
He stopped working on it a while ago. Last I talked to him he was working on a game with his friend, but the new semester started so he is probably busy with Eletrical Engeneering classes. Id be sick of merv too if I got junk mail from newbs all the time; instead I get a lot of email about making my shlong bigger. Powerbot is better than merv in many ways but requires a deeper understanding on how the game works. Switching from merv to powerbot is a little wierd, as it handles data a little differently, but overall they have a lot of people willing to help out and one very well documented header file; every line is commented and clear as to its purpose. It also has mysql support; that alone pretty much blows merv out of the water.
D1st0rt - Mon Jan 24, 2005 2:40 pm
Post subject:
Dr Brain swears by mysql
CypherJF - Mon Jan 24, 2005 4:42 pm
Post subject:
I like MySQL for what one does with it. I mean for a zone, for a local website, etc. it's fine. If you're running a corporation, etc. another DBMS, like Oracle, is much more appropriate. lol.
D1st0rt - Mon Jan 24, 2005 11:52 pm
Post subject:
doesn't oracle cost like $80,000 for a single license?
Dr Brain - Tue Jan 25, 2005 7:49 am
Post subject:
I like MySQL for storing dynamic data.

If I were running a corperation, I'd probably look into PostgreSQL.
Cyan~Fire - Tue Jan 25, 2005 3:56 pm
Post subject:
If I had time, I'd offer to continue development on MERV myself. But I don't.
Mr Ekted - Tue Jan 25, 2005 4:01 pm
Post subject:
I looked at adding Postgres support to PowerBot, but their file management is crap. Too many inter-dependencies. Trying to get it to build on my own (without using their make files) was a nightmare. I didn't want to take existing binaries because it wasn't clear what kind of compiler switches were used. This can be critical with single/multi-threading and various run-time switches.
CypherJF - Tue Jan 25, 2005 5:05 pm
Post subject:
*topic split requested. tongue.gif*
D1st0rt - Tue Jan 25, 2005 10:55 pm
Post subject:
How do you pronounce "Postgre"?
Underlord - Wed Jan 26, 2005 5:37 am
Post subject:
Quote:
50% Packetloss: "It also has mysql support; that alone pretty much blows merv out of the water."


here's a mysql ready template for mervbot: (not threaded)
http://www.dzleagues.com/bots/mysql
CypherJF - Wed Jan 26, 2005 1:20 pm
Post subject:
Was going to say, I used the backbone Underlord had on that site ^--- for a few of my projects. The only issue I had was when the bot got disconnected and attempted to re-connect; it'd stall merv and eat up memory. :/ I forget the exact details of why; and I don't think I ever fixed it lol... but that plugin is no longer in devel anywho... lol...

tongue.gif
Mr Ekted - Wed Jan 26, 2005 6:06 pm
Post subject:
DB access needs to be built into the core AND run in a separate thread because:

- DB calls will not block bots
- DB connections can be shared
- modules do not have to know anything about DB implementation (ie include mysql.h)

The typical cavalier attitude that MERV coders tend to have is to embed mysql calls into all modules that need them, trigger off some event (eg game end), and do all DB access in-thread waiting for server responses. This is wrong in so many ways, and one of the reasons PowerBot coders secretly (or even openly) hate MERV coders. It's not really their fault mostly; they have all learned by taking code samples they didn't understand and tweaked them until they compiled and did approximately what was needed, regardless of how efficient.
Solo Ace - Wed Jan 26, 2005 6:17 pm
Post subject:
Wow are there two completely different "coder" cultures in this "bot world" already?
That's uhm, pathetic? icon_smile.gif

Everyone has to start somewhere, and we all (well, there are exceptions) learn from our mistakes. sa_tongue.gif
D1st0rt - Wed Jan 26, 2005 10:41 pm
Post subject:
What about coders who take code samples, learn them, and then apply?
All times are -5 GMT
View topic
Powered by phpBB 2.0 .0.11 © 2001 phpBB Group