Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » Finished MUD Scripts
hatespyware
Apprentice


Joined: 16 Dec 2002
Posts: 103

PostPosted: Tue Oct 28, 2003 3:19 pm   

COM Wizardry and Bot AI
 
I haven't seen anyone else post anything illustrating how to use Perl/Python/Ruby/VB/whatever via zMud's COM support, so I thought I'd share. The benefits, aside from having what you would probably consider to be a better programming platform than zMud's own scripting abilities, include access to the rich APIs and modules of the parent language. For example, I use the same method outlined here to serve as the backend for zMud aliases that can translate to and from foreign languages, generate queries on google, correct my spelling, and all kinds of other nifty stuff. Interested yet? OK - first, you need to make sure that you have WSH support for whatever language you want to use (I'm assuming scripted, rather than compiled - else you should just create COM modules directly). If you have a normal Windows setup, you probably already have support for VB and ECMAscript (Javascript). In the case of Perl, this is best done (IMHO) by installing the [url="www.activestate.com"]Activestate[/url] distribution (a free download). Secondly, you will need some way of generating CLSIDs. The free WScript wizard from MS can generate lots of stuff for you, including CLSIDs, so it is a good idea to nab it, even if you already have a copy of guiden.exe or something similar. You can try looking for it here, or poking around here. I am going to demonstrate how to use all of these technologies together by showing you how to create a bot, since someone asked for help doing it in another forum. This will use Perl, primarily because I was already aware of an existing suitable AI module, but with a little bit of individual study and effort you should be able to adapt this to suit your choice of language and purpose.

Step 1: Install Chatbot::Eliza
Run the ppm utility that ships w/ Activestate's Perl, and type in "install Chatbot::Eliza"

Step 2:
Run the WScript wizard to generate the wsc file we're going to use. It doesn't really matter what info you give the wizard (except for the output filename), since all we really need from it is a valid CLSID/GUID.

Step 3:
Open the generated .wsc file with notepad or whatever text editor floats your boat. Alter it to look like this:
Code:

<?xml version="1.0"?>
<component>
<registration
   description="Eliza COM Module"
   progid="bot.WSC"
   version="1.00"
   classid="{f9fd8e76-9af3-425b-8e28-8da397232f39}"
>
</registration>
<public>
    <method name="Transform">
   <PARAMETER name="InputString"/>
    </method>
    <property name="LastOutput">
        <get internalName="GetOut"/>
    </property>
</public>

<script language="PerlScript">
<![CDATA[
use Chatbot::Eliza;
use vars qw($LastOutput);
$mybot = new Chatbot::Eliza("Hatespyware");
$mybot->{max_memory_size} = 25;
sub GetOut
{
    return $LastOutput;
}
sub Transform
{
    $InputString = shift @_;
    $LastOutput = $mybot->transform($InputString);
    return $LastOutput;
}
]]>
</script>
</component>

Those of you "in the know" will recognize this as an XML encapsulation of a Perl program. It will also soon be a full-fledged COM module. Very cool stuff.

Step 4:
Save the file as bot.WSC and close Notepad. Now, right-click on the .wsc file and choose register. You should get a message indicating success. If not, you need to check the file for errors (beyond the scope of this post). We now have a COM module that we can interact with via. zMud's scripting ability.

Step 5:
Access your COM module through zMud. Try something like this:
#CLASS {bot}
#ALIAS transform {#if (!@bot) { #VAR bot %comcreate( "bot.WSC")};#COM @bot.transform(%-1);#var botmsg %comget( @bot, LastOutput)}
#TRIGGER {(%w) tells you, "(*)"} {transform %2;reply @botmsg}
#CLASS 0

Step 6:
Have fun! There are tons of fun things that you could do w/ this module alone. The documentation that comes with it suggests having two bots talk to each other, for example. This could be hilarious! The mud that I play on (Age of Chaos), has a mob that reminds me of Eliza... a conversation between the two of them is just guaranteed to be fun!

quote:

Ankrag tells you, "I like pizza."
reply Why do you say you like pizza?
Ankrag tells you, "Because it's tasty!"
reply Don't any other reasons come to mind?
Ankrag tells you, "umm... because it goes well with beer?"
reply What other reasons might there be?
Ankrag tells you, "You act like you don't ever eat"
reply We were discussing you -- not me.



Postscript:
I know that using COM in this way is overkill. Most MUD clients, due to their *nix roots, have built in support for filtering their output through other programs. That kind of support would make stuff like this very much trivial, but past threads seem to indicate that Zugg (and the community in general) isn't interested. Must be related to the fact that the SDK generates $! At any rate, I hope that you find this useful and that you use it to do lots of stuff that all the morons said you couldn't/shouldn't do!
Reply with quote
gensubuser
Newbie


Joined: 11 Sep 2006
Posts: 5

PostPosted: Tue Sep 12, 2006 1:44 am   wow
 
I thought I was a trigger master.

I bot through entire zones, log every item I pick up, compare current who lists to determine players' alts, and automatically catalog eq.

I'd decided that I was going to show off my awesomeness by coding real tells encryption with RSA, including bigint math functions.

My kung fu is weak, though. Apparently other people interface with frickin Perl and javascript. Why work harder? I will never reach that level of awesomeness--the possibilities are just too endless once I open that door. Better formatting for eq searches, kill frequencies and histories, relentless logging of all sorts.

So yeah, no need to do all that coding, because there's already RSA javascript libraries out there.

It's fun to play a MUD where you know that all your scripting and hard work pays off. MUD's in general reward those who can put more effort (time, some skill) into it, and coding is just another level of extreme advantage. But wow.

And props to Zugg for a great app.
Reply with quote
Sir1l
Wanderer


Joined: 01 Oct 2005
Posts: 54

PostPosted: Sat Jun 16, 2007 8:49 pm   
 
When I try to register bot.wsc I get [19,9] The value for the attritube is not valid : language....how do I fix that :(
Reply with quote
Dharkael
Enchanter


Joined: 05 Mar 2003
Posts: 593
Location: Canada

PostPosted: Mon Jun 18, 2007 12:29 pm   
 
Do you have Perlscript installed?
This script requires Perlscript.
If you don't have it you can get it here.
_________________
-Dharkael-
"No matter how subtle the wizard, a knife between the shoulder blades will seriously cramp his style."
Reply with quote
Sir1l
Wanderer


Joined: 01 Oct 2005
Posts: 54

PostPosted: Fri Jun 22, 2007 10:25 pm   
 
Hmm, does anyone know where you can d/l alice like you do with eliza? Alice seems like a smarter bot, heh.
Reply with quote
Dharkael
Enchanter


Joined: 05 Mar 2003
Posts: 593
Location: Canada

PostPosted: Sat Jun 23, 2007 2:13 am   
 
This is a pretty good site to go for Alice stuff.
The site for the perl version of Alice wasn't up when I tried it, I'm not sure how permanent that is.
The site for the python version PyAIML is up.
You would still have to write your own COM interface to it, in Python if you wan't to go COM.
I'm not sure how smart the default bot is but you can also write your own AIML files which is what the bot uses to respond to stuff.
there are also some AIML files on http://www.alicebot.org/.
Anyways hope that helps a bit.
If you need some help writing the COM interface to the bot let me know.
_________________
-Dharkael-
"No matter how subtle the wizard, a knife between the shoulder blades will seriously cramp his style."
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » Finished MUD Scripts All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net