WAP BOT - University of Arkansascsce.uark.edu/~cwt/COURSES/2009-01--CSCE-5043--AI/TERM...2. When the...

10
WAP BOT Tejeshwar Sangameswaran [email protected] Arpita Barua [email protected] * Wickedly Awesome PHP Bot

Transcript of WAP BOT - University of Arkansascsce.uark.edu/~cwt/COURSES/2009-01--CSCE-5043--AI/TERM...2. When the...

Page 1: WAP BOT - University of Arkansascsce.uark.edu/~cwt/COURSES/2009-01--CSCE-5043--AI/TERM...2. When the user enters within the proximity of the wap-bot, he is greeted and told to touch

WAP BOT

Tejeshwar [email protected]

Arpita [email protected]

* Wickedly Awesome PHP Bot

Page 2: WAP BOT - University of Arkansascsce.uark.edu/~cwt/COURSES/2009-01--CSCE-5043--AI/TERM...2. When the user enters within the proximity of the wap-bot, he is greeted and told to touch

Abstract

Problem: The Second Life scripting language, LSL (Linden Scripting Language) has serious limitations. This limited capability and low fidelity of LSL makes complex tasks onerous or nearly impossible.

Goal:

1. The goal of this project is to build an asynchronous data transfer interface between Second Life and a HTTP server. This framework would allow data to be not only fetched from a server, but also seamlessly push data directly into Second Life.

2. The secondary goal of our project is to built on top of that framework, an autonomous bot which resides on a HTTP server outside Second Life which can perform tasks which were before not possible inside Second Life (mainly because of the limitations of the Linden Scripting Language. The limited capability and fidelity of LSL makes complex tasks onerous or nearly impossible.) .

Individual Objective :

Tejeshwar: My task was the create the the interface layer between Second Life and the webserver. To create the server and the plugin framework. My task was also to create the server front end interface which provides information about the connected client.

Arpita: To finalize the plugin architecture. Design plugins for use with the server. Fine tuning and testing the bot. Improve server frontend to display more information about the client.

Result : All the project details described in the abstract were successfully achieved over the course of the semester.

Implementation and Architecture

We have accomplished asynchronous data transfer by using two different protocols to send and receive data. To send/fetch data from the client to the server we use RESTful methods. To push data into Second Life client from outside we use XML-RPCs. This eliminating handshakes, and thus allows asynchronous data transfer.

This in fact produces a problem of keeping track of messages passed between the server and the client. So, we have created a session management system in PHP which uses a MySQL backend to store and manage client sessions.

Page 3: WAP BOT - University of Arkansascsce.uark.edu/~cwt/COURSES/2009-01--CSCE-5043--AI/TERM...2. When the user enters within the proximity of the wap-bot, he is greeted and told to touch

A real life example where this can be used is for example, if there is weather change; the server will capture the change and immediately push the new weather data into the mirror world and changes would take place immediately inside Second Life.

Components

Server

The server is coded in PHP and uses MySQL for its storage backend. The server opens up ports and waits for an incoming connection. As of now, the server is programmed to accept and work with only one client at a time.

As soon as the user connects, session variables are created to track data flow. The server acts a bridge between the Second Life wap-bot client and services available on the internet.

The server first and foremost empower users to get various (real-time) data with language-based instructions. The server enables on-demand data through mashups and extend and enhances the functionality of Second Life.

Page 4: WAP BOT - University of Arkansascsce.uark.edu/~cwt/COURSES/2009-01--CSCE-5043--AI/TERM...2. When the user enters within the proximity of the wap-bot, he is greeted and told to touch

The server reduces several complicated and repetitive tasks easy through intuitive user-centric commands. The server acts like a kiosk.

Client

The main function of the client is to open up two different channels for xml-rpc and http requests. Once the channels are opened and successfully connected to the server, the user can type in messages to the wap-bot; which processes the information on the server side and replies to the user with the desired results.

All the processing is seamless and completely done in the background, so the user has a pleasant non obtrusive experience.

Server Plugins

The server plugins are attached to the server and easily expand the horizons of the server. These are little modules that act as interfaces to information on the web. They are mashups which fetch and clean information for client.

Current developed plugins:

News: Fetches the headlines from current top stories. Can fetch separate stories for Technology, Health, Entertainment and Business news.

Syntax: news <headlines|health|entertainment|business>

Weather: Fetches weather for any specified city (or zip code) in both Celsius and Fahrenheit.

Syntax: weather <city>Syntax: weather Fayetteville,AR

Calculate: Processes and solves any algebraic questions.Syntax: calculate <expression>Syntax: calculate 55-44*32/2

Question: An 8ball implementation for an illusive AI.Syntax: question <any question!>Syntax: question Will I ever find true love?

Dictionary: Fetches definitions of wordsSyntax: dictionary <any word>Syntax: dictionary complicated

Roll: Rolls a dice, and tells the value on face of dice.Syntax: roll dice

Page 5: WAP BOT - University of Arkansascsce.uark.edu/~cwt/COURSES/2009-01--CSCE-5043--AI/TERM...2. When the user enters within the proximity of the wap-bot, he is greeted and told to touch

Plugin Architecture

• Each plugin followed a standardized architecture.• They all built and have a similar set of function which describe it.• Its got functions that return the syntax, what the function does and plug in

definition.• The plugin has a standardized process() function which is the first

function which is called when the plugin in initiated (Analogous to a constructor)

• When the server is initialized, it scans all the plugins, builds a plugin database and generates a command sensitivity list.

• When ever the server encounters the matched keyword, it imitates the plugin process.

• The server has a unified command set, so it interface with all plugins in a similar fashion

• As of now, the plugin architecture is only on paper. It is yet to be implemented.

Sample Plugin:

weather_plugin.php

//plugin for retrieving weather informationinclude “pxweather.class.php” //3rd party api for parsing weather from weather.comfunction initialize(){

$arr = array('description'=>'Returns the weather', 'parameters'=>'Zip code', 'trigger'=>'weather',//keyword 'process'=>'weather',//keyword 'params'=>'varchar', //parameter datatype 'return'=>'varchar');//return datatype

return $arr; //for registering with server.}function process($param){

return getWeather($param);}//after this, this code is custom code for individual plugins.function getWeather($zip){

$w = new Weather($zip);$w->load();return $w->getCurrent("temp.string"); //uses the PxWeather API to pull weather

data.}

Page 6: WAP BOT - University of Arkansascsce.uark.edu/~cwt/COURSES/2009-01--CSCE-5043--AI/TERM...2. When the user enters within the proximity of the wap-bot, he is greeted and told to touch

Results

1. All the described components were successfully implemented. Except for the plugin architecture.

2. When the user enters within the proximity of the wap-bot, he is greeted and told to touch to object to initiate a connection.

3. Once the channel is established, the user can connect to the server to establish a new session. ➔ The syntax is connect <channel-key>

4. Once the connection is established,➔ Once the user is in the proximity of the chatbox➔ He can use the chat box to interact with the wap-bot

5. To disconnect from the server, the user simply touches the bot again➔ The user can also disconnect by using disconnect command.

Screen Shots

Touch the wap-bot, it gives you instructions to connect to it.

Page 7: WAP BOT - University of Arkansascsce.uark.edu/~cwt/COURSES/2009-01--CSCE-5043--AI/TERM...2. When the user enters within the proximity of the wap-bot, he is greeted and told to touch

Connect using the connect keyword.

Once connected, you can interact with the bot.

Page 8: WAP BOT - University of Arkansascsce.uark.edu/~cwt/COURSES/2009-01--CSCE-5043--AI/TERM...2. When the user enters within the proximity of the wap-bot, he is greeted and told to touch

Disconnect from the bot by just touching the object again.

Server interface shows client session information and illustrates the push data feature. (http://microep.uark.edu/secondlife)

Page 9: WAP BOT - University of Arkansascsce.uark.edu/~cwt/COURSES/2009-01--CSCE-5043--AI/TERM...2. When the user enters within the proximity of the wap-bot, he is greeted and told to touch

Installation Instructions

• In the included source code package, there is a 'Client' and 'Server'.• The client has two lsl scripts; the xmlrpc and httpreq, each setup two

individual communication layers. They should be put into the same object.

• The server has several files and dependencies. They all need to be placed with the folder structure preserved into the webserver.

• The lsl client script 'httpreq' has a reference to the httpreq.php file on server, this needs to modified and pointed to the right url.

• The cache folder and pretty much all the files on the server should have rwxrwxrwx

Conclusions and Thoughts

• As you can see, the bot is very intuitive and greatly improves the user experience.

• This framework can be easily reused for several different scenarios

Testing

• The testing was mainly Ad-hoc based. • Unit Testing was done on the server side php functions.

Future Developments

A lot of advancements can be made to this framework to take this to the next level.

Immediate Future:• Implement the plug in framework.• Implement a chat interface between a website and Second Life: That way

people on a website can directly talk to the player• Multithreaded server to accept several client connections

Future:• Modify Second Life environment based on data pumped into it making the

it more closer to reality.

Page 10: WAP BOT - University of Arkansascsce.uark.edu/~cwt/COURSES/2009-01--CSCE-5043--AI/TERM...2. When the user enters within the proximity of the wap-bot, he is greeted and told to touch

• Terminal Based Services: Since we have an framework built, we can build a client (similar to telnet) from inside Second Life to control a unix machine.

Distant Future:

• Implement a full featured AI: Create a plugin that will be a full feature AI that will be based on ALICE. A bot that can talk back , respond and maintain a conversation with a user.

Bibliography

3 rd Party API:

1. pxWeather - Jonathan Abbett2. RSS_PHP – rssphp.net

Special Thanks:

3. Dr.Craig Thompson – Teaching us about various software design paradigms and helping us refine our knowledge about software implementation.

4. Keith Perkins – Valuable information about communication protocols within Second Life.

References:

5. http://wiki.secondlife.com/wiki/LSL_http_server/examples 6. http://sec-c.org/wp-content/uploads/2009/01/irc-bots.pdf 7. http://www.lslwiki.net/lslwiki/wakka.php?wakka=XMLRPC