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

No comments: