collapse collapse
* User Info
 
 
Welcome, Guest. Please login or register.
* Search

* Board Stats
  • stats Total Members: 989
  • stats Total Posts: 18366
  • stats Total Topics: 2501
  • stats Total Categories: 7
  • stats Total Boards: 35
  • stats Most Online: 1144

Author Topic: Multibots  (Read 5054 times)

0 Members and 1 Guest are viewing this topic.

Offline Glarawyn

  • BeBot Hero
  • ******
  • Posts: 521
  • Karma: +0/-0
Multibots
« on: October 29, 2008, 06:12:26 pm »
I'm wondering if muti-bots (bots that use one main bot and multiple "slave" bots to do messaging) could be handled better.

What we've done on Campalot is create a core module for the main bot that has the functionality for ordering the other bots around. For example, when an alert is sent out instead of having the main bot send out the message, the main bot sends a command (via tell) to the other bots who then start ending alert messages.

It works, but it's somewhat hackish and lacks flexibility.

Alternatives include writing to a database table, but then each bot has to constant query the database. Not exactly ideal.

What other options could be used for communicating between bots that are running under the same server?

Is there some trickery that could be used to run StartBot.php and have all the bots start up and be managed under one controlling process?

Other ideas? What I'd like to be able to do for example is have a mass alert go out and then allow users to reply to that tell to join the main bot. Again we could fall back to tells or spam at a private group, but I'm still wondering if there are better/other options...


Offline Temar

  • Contributor
  • *******
  • Posts: 1140
  • Karma: +0/-0
    • AoFiles
Re: Multibots
« Reply #1 on: October 29, 2008, 07:33:21 pm »
ive tried starting all bots inside startbot.php but due to the way php is, it tends to only boot 1st and wait till that is no longer running.

Offline Tefnacht

  • BeBot Rookie
  • *
  • Posts: 5
  • Karma: +0/-0
Re: Multibots
« Reply #2 on: October 30, 2008, 05:28:15 pm »
The best way to handle multi-bots like you describe them would be to have a single script "spawn" multiple connections to the chatserver instead of just one. All incoming messages would then be handled in the same "handling object" of the same bot. They would no longer have only a single "channel/group/player" name/ID as origin, but also the connection that received them.
In this design it would be trivially easy to receive a command with "bot A" and act on it with "bot B". Mass message spamming and buddy lists over 1k people also become very simple to implement. There is no longer the need for an extra "communication layer" between the sepearate bots.

I doubt that it would be practical to "rewrite" BeBot to support this though. The very essence of what makes the bot "tick" needs to be changed significantly.
AOChat.php cannot be used for this (the sockets communication implementation is too naive) but you can keep the AOChatPacket class and copy&paste the crypto stuff.

The tricky part is to come up with a good sockets implementation that stays fully responsive, no matter how many sockets are actually used. It should be low on CPU load when it is just "waiting". It should also allow for flexible cron jobs. The PHP function socket_select can monitor any number of sockets and it can also be given a timeout.
One possible implementation looks like this:

1.) Go through list of cronjobs, execute those that have expired (and maybe restart them).
1a.) While doing that, also find the one cronjob that expires next and remember the time until it does.
2.) If we have a next cronjob expire time, calculate sec and usec part out of it which is given to socket_select as a timeout.
3.) Put all listening sockets and sockets that wait for data into the read array.
4.) Put all those sockets that have data in their objects write queue into the write array.
5.) Give read/write arrays and timeout to socket_select. Now socket_select is in control of the script. It will return control once the timeout expired (to execute a cronjob) or until a socket is ready to read/write.
6.) Write to all sockets that socket_select reported as "ready to write"
7.) Read from all sockets that socket_select reported as "ready to read" (and maybe act on it)
8.) Start over at 1

This implementation allows any number of chatserver connections (until Funcom starts to block your IP because you have too many). Downloading a XML file or any other data will be done in the same loop (reading and writing would be done by a "FileDownload" socket object and not the "BotCore" socket object in that case).
The cron jobs are _very_ flexible. You can choose any interval you want, from 1ms to many hours. They are not super accurate though. They will always expire a little later than you want but the error will be very small (< 100ms).
While socket_select is in control and waiting for a socket event, CPU load is minimal.

If people are interessted I could post a script snippet from my bots "master loop" that does what I described above. With some explanations that would be another "wall of text", so I didn't add it this time.

---

If you must work with multiple bot scripts (a few BeBots) then using ingame tells to communicate between them is probably the easiest solution. Personally I would prefer to use a local sockets connection between the two (or more) scripts because sending a command over the internet to FC and then back to the very same computer where it came from doesn't make much sense to me... but implementing that is probably as much work as rewriting the bot core to support multiple connections...

Offline Temar

  • Contributor
  • *******
  • Posts: 1140
  • Karma: +0/-0
    • AoFiles
Re: Multibots
« Reply #3 on: October 30, 2008, 05:39:32 pm »
well useing ingame relaying has the advantage of not needing to be same host
yer useing a direct conection useing sockets for relay might be good also

right now im working on slave module which makes extra connections for buddy handleing and mass msg all in the same script

 

* Recent Posts
Com bot module by bitnykk
[November 25, 2024, 05:36:11 pm ]


0.8.x updates for AO by bitnykk
[June 23, 2024, 03:19:47 pm ]


0.8.x updates for AoC by bitnykk
[June 23, 2024, 03:19:44 pm ]


[AoC] special char for items module by bitnykk
[February 09, 2024, 09:41:18 pm ]


BeBot still alive & kicking ! by bitnykk
[December 17, 2023, 12:58:44 am ]

* Who's Online
  • Dot Guests: 75
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.
* Forum Staff
bitnykk admin bitnykk
Administrator
Khalem admin Khalem
Administrator
WeZoN gmod WeZoN
Global Moderator
SimplePortal 2.3.7 © 2008-2024, SimplePortal