• Welcome to Valhalla Legends Archive.
 

Threaded Bot

Started by OriOn, February 11, 2003, 08:52 PM

Previous topic - Next topic

OriOn

Hello all

What brings the thread-programmation of a bot ?
And which part do u threaded ?

Sorry my english is poor

OriOn-

Yoni

#1
Thread programmation sure is fun, but it is usually unneeded.
For example, BinaryChat (*cough*) can run many profiles (as many as your RAM allows) each with 2-3 sockets and do this all in one thread. This is achieved by using I/O completion to be notified of Winsock events, instead of kernel event handles or windows messages. (Requires Winsock 2.0.)

The only times you would want to use multithreading is when:
1) The API doesn't allow otherwise.
2) You want to optimize your application (usually a big server) for dual- or multi-processor machines.

Brand.X

#2
One advantage of multithreading, is if you get stuck in an infinite loop it won't freeze your program. ;)

tA-Kane

#3
No, it'll just freeze that thread.

Hopefully, if that happens, hopefully you've implemented the API call to kill and delete that thread. Otherwise, you've a rogue thread wasting resources.
Macintosh programmer and enthusiast.
Battle.net Bot Programming: http://www.bash.org/?240059
I can write programs. Can you right them?

http://www.clan-mac.com
http://www.eve-online.com

Skywing

#4
QuoteOne advantage of multithreading, is if you get stuck in an infinite loop it won't freeze your program. ;)
Actually, you'll probably have to use some kind of synchronization mechanism to protect any real code, so the odds are that your program would still lock.

Adron

#5
Another advantage is if you have tasks that may take a while to execute and you want other tasks to preempt them. By using threads you won't have to write your own code for that (that implements threads).

Skywing

#6
QuoteAnother advantage is if you have tasks that may take a while to execute and you want other tasks to preempt them. By using threads you won't have to write your own code for that (that implements threads).
Enjoy QueueUserAPC and IO completion.

Eibro

#7
"Programming C++ Applications for Microsoft Windows" by Jeff Richter has a bunch of info on when/when not to thread your applications; you usually thread when it makes sense to thread :). I'm sure you can find an ebook around somewhere, many people have it.
Eibro of Yeti Lovers.

Adron

QuoteEnjoy QueueUserAPC and IO completion.

Hmm, not quite clear to me how those will make your bot respond while it's processing this:
double x, y;
double limit = 100000;
int i;
complex<double> a(-0.74543, 0.11301);
for(x = -2; x < 2; x += 0.001)
  for(y = -2; y < 2; y += 0.001) {
    complex<double> c(x, y);
    for(i = 1; i < 10000000; i++) {
      c *= c;
      c += a;
      if(c.real()*c.real() + c.imag()*c.imag() > limit)
        break;
    }
    SetPixel((x + 2) * 1000, (y + 2) * 1000, ColorMap(i));
  }

edit: code tags

Skywing

#9
QuoteHmm, not quite clear to me how those will make your bot respond while it's processing this:
double x, y;
double limit = 100000;
int i;
complex<double> a(-0.74543, 0.11301);
for(x = -2; x < 2; x += 0.001)
  for(y = -2; y < 2; y += 0.001) {
    complex<double> c(x, y);
    for(i = 1; i < 10000000; i++) {
      c *= c;
      c += a;
      if(c.real()*c.real() + c.imag()*c.imag() > limit)
        break;
    }
    SetPixel((x + 2) * 1000, (y + 2) * 1000, ColorMap(i));
  }

edit: code tags
Naturally you use QueueUserWorkItem to execute that.

Why would a bot be graphing fractals, anyway? :P

Adron

#10
QuoteNaturally you use QueueUserWorkItem to execute that.

Why would a bot be graphing fractals, anyway? :P

QueueUserWorkItem would require you to have multiple threads though :P

And regarding fractals, wouldn't that be pretty nice to have as a background for the channel? ;)

iago

#11
Quote"Programming C++ Applications for Microsoft Windows" by Jeff Richter has a bunch of info on when/when not to thread your applications; you usually thread when it makes sense to thread :). I'm sure you can find an ebook around somewhere, many people have it.

ftp://Guest:[email protected]:665/windows.chm

I'm not positive about the filename, but it should be somewhere on there anyway :)
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*