I, robot.c
Mon Oct 4th 2004, 3:01pm
While cleaning out my home office I ran across a printout of an old C program I wrote back in my college mudding days. Talk about nostalgia. The program is a very primitive robot that would log into my favorite MUD, Mordor, and perform some simple tasks, including sitting in a corn field and killing crows as they would occasionally drift in. Even with my bungling coding abilities at the time, killing the crows was simple enough that the robot managed to stay alive while slowly racking up experience points. Well, mostly, as I recall :-). If I left the robot running all night on a brand new character, by morning I would usually find my character had enough experience to jump from level 1 to 4. Fun, and practical: it eliminated some of the tedium in getting a new character off the ground. Really neat stuff. Pretty soon I got more excited about programming and enhancing my robot than I did about actually playing the MUD, and so at last one time sink was replaced by another.

Just for fun, here's a snippet of code, or you can grab the full source, last modified April 28, 1994. Fortunately I found I still had an electronic copy of it, buried in the recesses of my home directory. It is, of course, provided "as is", without any expressed or implied warrantees, and it's almost certainly of no use to anyone sane. Some truly frightening stuff :-).


void readmsg (char *msg) {

  char temp[50];
  char temp2[80];
  int i=0;

  if (MASTER != NULL) {
    sprintf(temp, "### %s just flashed", MASTER);
  }

  if (debug) fprintf (stderr, "Msg: %s\n", msg);

  if (strindex(msg, "how much xp?") &&
      strindex(msg, "just flashed"))
    report(msg); 

  if (strindex(msg, "how much xp?") &&
      strindex(msg, "broadcasted"))
    broad_report();    

  else if (MASTER != NULL)
    if (strindex(msg, temp))
      command (hackoff(msg));

/*  else if (strindex(msg, "just flashed"))
    forward (msg);
*/

  else if (strindex(msg, "stinks up") && (strindex(msg, MASTER))) {
    strcpy(temp2, "give sc ");
    strcat(temp2, MASTER);
    for (i=0; i < 20; i++)
      sendmud(temp2);
  }

  else if (strindex(msg, "sucks you") && strindex(msg, MASTER))
    sendmud("clear ignore");
  else if (strindex(msg, "hugs you") && strindex(msg, MASTER))
    sendmud("set ignore");

  else if (strindex(msg, "just arrived") && 
           (solo) &&
           (enemy == NULL)) {
    if (prepare(msg)) {  /* if attackable monster, returns TRUE when ready */
      attack(msg);
    }
  } 

  else if (strindex(msg, "gave a hornblade to you") && (solo)) {
    sendmud("put horn br");
    sendmud("say thanks!");
    sendmud("smile");
  }

  else if (strindex(msg, "bag is full") && (solo))
    sendmud("drop horn");

/*  else if (strindex(msg, "does not exist"))
    forward (msg);
*/

  else if (strindex(msg, "You failed to escape")) {
    hangaround(3);
    flee();
  }

  else if (janitor) {
    if (strindex(msg, "### Shutting down in"))
      janitor_still_need = 0;
  }

  else if (strindex(msg, "### Shutting down now") && (solo))
    quit_robot(5);   

}