Showing posts with label open metaverse. Show all posts
Showing posts with label open metaverse. Show all posts

Friday, 2 October 2009

AIMLBot and Open Metaverse

To remove any hard work in creating a chat bot using Open Metaverse, I performed a search for C# AIML parsers. Top of the list was AIMLBot (http://aimlbot.sourceforge.net/), and after a bit of poking around they seem to work well together.


There was some head scratching because the chat example on the Open Metaverse page (http://lib.openmetaverse.org/wiki/Respond_to_inworld_chat) seems to be out of date - the LL prefix from LLUUID and LLVector3 seem to have been dropped. The AIMLBot also doesn't come with the xml and aiml files needed, but I just took those from Radegast.

As it stands the chat call back is fired whenever anyone starts typing nearby, and when it hears itself. My slap-dash solution is included below:


static void Self_OnChat(string message, ChatAudibleLevel audible,
ChatType type, ChatSourceType sourceType, string fromName,
UUID id, UUID ownerid, Vector3 position)
{
if (message != "")
{
if (fromName != "Test Bot")
{
//process chat here
AIMLbot.Request request = new AIMLbot.Request(message,
myUser, myBot);
AIMLbot.Result reply = myBot.Chat(request);

Client.Self.Chat(reply.Output, 0, ChatType.Normal);
Console.WriteLine(reply.Output);
}
}
}


That's the main component of the chat bot, so you can see that it is very easy to implement.

Friday, 25 September 2009

Creating Bots for SL/OpenSim

If you have any exposure to Second Life culture, then you will hear discussions about 'bots' - which are simply avatars controlled by computers, rather than by real human beings. For example, when you perform a search for places in SL, the results are ordered based on traffic, with the places that have had the most visitors listed at the top. Some unscrupulous people used bots to inflate their traffic stats to move up the search list. Also, how do you know that the preset grinding sequence of the SL stripper you just paid was initiated by a person and not a computer? Do you care? Should you care? Why are you there?

Regardless of the controversies, bots are very useful as NPCs. Compared to the alternative on in-world modelled and scripted bots, out-world bots will generally look better (using the avatar mesh and any of the high-quality garments and animations you choose to purchase) and have potentially better AI. I will now share with you the knowledge gained from a brief investigation into how to create these bots, with specific consideration to OpenSim.

Important note: Every bot neads a valid login account.

Easy-Peasy Method:

The Radegast client (http://radegastclient.org/wp/) is a non-graphical client for SL. It supports almost everything you might want to do in SL, except look at it, and also includes a built-in AI agent based on A.L.I.C.E. You just turn it on as a setting, and when anyone enters chat nearby that includes the avatar's firstnname (this is very important), then Alice will repond.

I.e. If you log in as Rupert Marmaduke, and somebody says "Hello Rupert Marmaduke" or "Hello Rupert", then they will illicit some suitable response.

For OpenSim, you will need to set a URL and port in order to connect (e.g. http://127.0.0.1:9000).

Personalising Radegast (Maybe):

As mentioned the Radegast chat-bot is built upon A.L.I.C.E, which uses aiml definitions. Basically these are xml files, listing patterns (what the user might say) and templates (how the bot might respond). For example:

<category>
<pattern>TELL ME ABOUT YOURSELF</pattern>
<template>I am a natural language chatterbot, that talks to people via computer networks such as the Internet.</template>
</category>

You can conceivably modify the aiml files that come with Radegast (stored in Program Files\Radegast\aiml) as you see fit. Whatever you put in the template section is regurgitated whenever the pattern is matched. I have not tried this, but I'm 90% sure that it would work.

Getting Complex: OpenMetaverse

If you want to get your hands dirty then you can download a C# library called Open Metaverse - and it is what Radegast was built upon. There are plenty of examples provided, and it is very easy to get an avatar to login and say something (i.e. follow 5 instructions then copy and paste). Capturing the surrounding chat and responding intelligently is obvioulsy the biggest challenge.

By default the library connects to SL, but you can switch to any grid using:

client.Settings.LOGIN_SERVER = "http://osgrid.org:8002/";
Full details are given here: http://lib.openmetaverse.org/wiki/How_to_create_a_basic_libopenmv_bot_for_osgrid%3F