Page 1 of 1

Multiple autopilot clients, without graphics

Posted: Sun Apr 15, 2007 1:56 pm
by duongtnb
Hi there,

I am looking for a way to start multiple autopilot clients without graphics (to reduce cpu consumption) on a single physical machine. Any one knows how to do that?

What I actually want to do is to stress-test the bzflag server, by starting many clients connecting to the same server.

Thanks.

Posted: Sun Apr 15, 2007 2:53 pm
by joevano
Well the real issue with BZFlag is not the server, it is with the internet bandwidth. Most servers run below 10% utilization even with 30 or 40 clients connected. Where the bottleneck is is in network bandwidth. The bandwidth required increases exponentially for each player that joins, as all updates must be sent to another client and the updates get larger because there is another client. On my T1 (1.5Mbs) we can handle about 30-35 players before jitter and lag start to increase. Yet the server barely even shows that it is working.

Posted: Sun Apr 15, 2007 3:28 pm
by duongtnb
Hi, thanks for the quick reply, and the information.

However, I still like to know if there's any way to do it, i.e., start multiple autopilot clients without graphics on a single physical machine. Any help would be greatly appreciated.

Posted: Sun Apr 15, 2007 3:38 pm
by Teppic
I have a hackish way of doing it, the client starts in a 10x10 window, logs on, starts itself in autopilot mode, and minimizes itself. Once it's running minimized it uses nothing for gfx processing, I can get 12~15 running on a 3.2G P4 with 1/2 gig of ram.

Posted: Sun Apr 15, 2007 3:52 pm
by duongtnb
Can it be done programmatically, e.g., starting 50 autopilot clients connecting to a given server using shell script? Put another way, do we have ways for a client to go to autopilot and minimize itself? Otherwise, we have to manually start each client, put it into autopilot mode (press 9) and then minimize it.

Thanks.

Posted: Sun Apr 15, 2007 4:17 pm
by Saber
Why not using the -solo thing to start multiple bots. Then just minimize the client. I've never tried and I don't know if they are all going to be [nr]. And I think they won't be as "smart" as the auto-pilot.

Posted: Sun Apr 15, 2007 4:22 pm
by JeffM
duongtnb
no it can not be done that way right now, you'd have to modify the client. it would not be that hard.

Posted: Sun Apr 15, 2007 6:49 pm
by Teppic
JeffM2501 wrote:you'd have to modify the client.
That's what I have done, I'll hunt out the patch...
And no, it wasn't hard.

EDIT:

Code: Select all

diff -urN -x '*.o' -x '*.in' bzflag/src/bzflag/LocalPlayer.cxx bzrobot/src/bzflag/LocalPlayer.cxx
--- bzflag/src/bzflag/LocalPlayer.cxx   2005-11-03 16:21:06.000000000 +0000
+++ bzrobot/src/bzflag/LocalPlayer.cxx  2005-12-27 15:08:03.000000000 +0000
@@ -286,10 +286,8 @@
        }
        setStatus(PlayerState::DeadStatus);
        location = Dead;
-       if (isAutoPilot()) {
-         CMDMGR.run("restart");
+    CMDMGR.run("restart");
        }
-      }

       // can't control explosion motion
       newVelocity[2] += BZDBCache::gravity * dt;
@@ -1185,11 +1183,9 @@
 {
   if (autopilot && !isAutoPilot()) {
     setAutoPilot();
-    server->sendAutoPilot(true);
   }
   else if (!autopilot && isAutoPilot()) {
     setAutoPilot(false);
-    server->sendAutoPilot(false);
   }
 }

diff -urN -x '*.o' -x '*.in' bzflag/src/bzflag/clientConfig.cxx bzrobot/src/bzflag/clientConfig.cxx
--- bzflag/src/bzflag/clientConfig.cxx  2005-10-21 03:04:51.000000000 +0100
+++ bzrobot/src/bzflag/clientConfig.cxx 2005-12-27 15:08:51.000000000 +0000
@@ -92,7 +92,7 @@

 std::string getCurrentConfigFileName(void)
 {
-       std::string configFile = BZ_CONFIG_FILE_NAME;
+       std::string configFile =  "robot.cfg";

        std::string name = getConfigDirName(BZ_CONFIG_DIR_VERSION);
        name += configFile;
diff -urN -x '*.o' -x '*.in' bzflag/src/bzflag/playing.cxx bzrobot/src/bzflag/playing.cxx
--- bzflag/src/bzflag/playing.cxx       2005-12-05 01:29:39.000000000 +0000
+++ bzrobot/src/bzflag/playing.cxx      2005-12-27 15:05:18.000000000 +0000
@@ -88,6 +88,7 @@
 #include "World.h"
 #include "WorldBuilder.h"
 #include "HUDui.h"
+#include "JoinMenu.h"

 //#include "messages.h"

@@ -1729,6 +1730,7 @@
     case MsgSuperKill:
       printError("Server forced a disconnect");
       serverError = true;
+      joinGame();
       break;

     case MsgAccept:
@@ -1995,7 +1997,7 @@
       Player* tank = lookupPlayer(id);
       if (!tank) break;
       tank->setAutoPilot(autopilot != 0);
-      addMessage(tank, autopilot ? "Roger taking controls" : "Roger releasing controls");
+      //addMessage(tank, autopilot ? "Roger taking controls" : "Roger releasing controls");
       break;
     }

@@ -2074,7 +2076,7 @@
                  char meaculpa[MessageLen];
                  memset(meaculpa, 0, MessageLen);
                  strncpy(meaculpa,
-                         "sorry, i'm just a silly machine",
+                         "sry",
                          MessageLen);
                  char *buf = messageMessage;
                  buf = (char*)nboPackUByte(buf, victimPlayer->getId());
@@ -2304,7 +2306,7 @@
            if (myTank->isAutoPilot()) {
              char meaculpa[MessageLen];
              memset(meaculpa, 0, MessageLen);
-             strncpy(meaculpa, "sorry, i'm just a silly machine", MessageLen);
+             strncpy(meaculpa, "sry", MessageLen);
              char *buf = messageMessage;
              buf = (char*)nboPackUShort(buf, myTank->getTeam());
              nboPackString(buf, meaculpa, MessageLen-1);
@@ -4116,6 +4118,7 @@

 static void enteringServer(void *buf)
 {
+  mainWindow->iconify();
   // the server sends back the team the player was joined to
   void *tmpbuf = buf;
   uint16_t team, type;
@@ -4216,6 +4219,8 @@
   BZDB.setBool("displayConsole", true);

   entered = true;
+  CMDMGR.run("restart");
+  myTank->activateAutoPilot();
 }

 static void cleanWorldCache()
@@ -4614,10 +4619,12 @@
        // the server is having network problems.
        HUDDialogStack::get()->setFailedMessage
          ("Game is full or over.  Try again later.");
+       joinGame();
        break;

       case ServerLink::SocketError:
        HUDDialogStack::get()->setFailedMessage("Error connecting to server.");
+       joinGame();
        break;

       case ServerLink::CrippledVersion:
diff -urN -x '*.o' -x '*.in' bzflag/src/date/buildDate.cxx bzrobot/src/date/buildDate.cxx
--- bzflag/src/date/buildDate.cxx       2005-10-02 02:09:14.000000000 +0100
+++ bzrobot/src/date/buildDate.cxx      2005-12-27 16:15:24.000000000 +0000
@@ -152,7 +152,7 @@
     std::ostringstream appVersionStream;
     // TODO add current platform, release, cpu, etc
     appVersionStream << getMajorMinorRevVersion() << "." << BZ_BUILD_DATE
-       << "-" << BZ_BUILD_TYPE << "-" << BZ_BUILD_OS;
+       << "-TepBot-Client-" << BZ_BUILD_TYPE << "-" << BZ_BUILD_OS;
 #ifdef HAVE_SDL
     appVersionStream << "-SDL";
 #endif
Coolio, it patches 2.0.8 too (was written for 2.0.6). This one doesn't shrink the screen to 10x10, that version had loads of other useless nasty hacks in it (like ignoring ST and CL).

Unpack the source, cd into bzflag-2.0.8, paste the patch as robot.patch, then run

Code: Select all

patch -p1 < robot.patch
then compile as normal. I tend to copy the bzflag binary as bzrobot to $PATH somewhere. The robot client has it's own config file too (robot.cfg instead of config.cfg) so you can turn all the setttings down and not have it affect your normal game. Run it with

Code: Select all

bzrobot -window -directory /usr/share/games/bzflag/data -team auto -g 10x10 robot1@some.server.com:5154

Posted: Sun Apr 15, 2007 7:23 pm
by Teppic
Hey, I found the original thread http://my.bzflag.org/bb/viewtopic.php?t=7630

Posted: Wed Apr 18, 2007 2:48 pm
by duongtnb
Thanks so much, Teppic, for the detailed instruction :D. I'll try this and let you guys know.