a.i. in second life akihiro eguchi. why second life? real world like environment where we can...

Post on 11-Jan-2016

218 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

A.I. in Second Life

Akihiro Eguchi

Why Second Life?Real world like environment

where we can visually show the demo of our work

E.g.◦Workflow◦Ontology◦Smart Object◦Autonomous Avatar Navigation◦Avatar Capable of Logical Reasonings◦Chatbots …

Retail Workflow

http://www.youtube.com/watch?v=_KY5LwFy-4s

Smart Objects

http://www.youtube.com/watch?v=Je3As2Vp6gU

Akihiro Eguchi, Craig W. Thompson, "Towards a Semantic World: Smart Objects in a Virtual World," International Journal of Computer Information Systems and Industrial Management, Volume 3, 2011. pp. 905-911.[pdf]

Autonomous Avatar Navigation

http://www.youtube.com/watch?v=kO8FQt7yXcs

Hung Nguyen, Akihiro Eguchi, Daniel Hooten, "In Search of a Cost Effective Way to Develop Autonomous Floor Mapping Robots,"9th IEEE International Symposium on Robotic and Sensors Environments (ROSE 2011), 2011, Montreal, Canada.

Other Related WorksRPI Demo of Eddie, The Four-Year-Old Av

atarChatting with an AI in Second Life Automated Avatars in Second LifeAI patient in second life using scripted pri

m and challenge responseJoshua Eno, Craig Thompson, "Virtual (and

Real) World Ontology Services," IEEE Internet Computing, 16 May. 2011. IEEE computer Society Digital Library. IEEE Computer Society.

and etc..

How to program in SLTutorial of Linden Scripting Language

Create an account

1. Visit https://join.secondlife.com to create your account

2. Send me the account so that I can register you to U of A. island

3. Download and Install the Viewer4. Search U of A. island and

teleport

Learn how to controlWalk

Run

Fly

Control View + drag mouse

Creating ObjectsRight click any place in the island

to EditChoose Create button

Pick one shape and click any location where you want to place the prim at.

Editing ObjectIf you click the object,

you can change the xyz coordinate

Rotate the object with keep pressing Ctrl

Change the size of the object with keep pressing Ctrl + Shift

Link Objects togetherShift + click objects you

want to link togetherThen, Ctrl + L to linkIf you want to edit only a

part of linked object, click Edit linked.

STATES

A "State" in LSL is a section that is running, and waiting for events.

Only one state can be active at a time per script.Every script must have a default state.Except for the default state, each state is defined by the word STATE followed by the name of the state.

EVENTS

Events are inside of states. When that state is active, those events wait to be triggered and run the code inside them.

"state_entry": triggered by the state being entered

"touch_start": triggered when anyone touches an object.

FUNCTIONSFunctions lay inside of events.Built in functions:

◦all start with two lowercase L's. E.g., llSay(0, "Hello")

◦llSay takes arguments of a number and a string.

User define functions:◦You can define own function before

default◦E.g.:

sayOutloud(string message) {

llSay(0, message);}

Scripting! Right Click Object -> edit -> Content ->

New Script -> Open New Script

This script will basically say "Hello, Avatar!" on the public channel which is 0, and will then say "Touched." on the public channel when a user touches or clicks it.

Output in a chat box10m range:

◦ llWhisper(Channel, "WHISPER STUFF");20m range

◦ llSay(Channel, "SAY STUFF ");100m range

◦ llShout(Channel, "SHOUT STUFF"); Anywhere on the region

◦ llRegionSay(Channel, "REGION SAY STUFF"); Use Channel 0 to talk, others (-

2147483648 ~ 2147483647) for obj-to-obj communication

LSL variables examplesinteger count = 2; //A whole number

float measure = 1.2; //A number with decimal places

string chars = "Lee"; //Any text within " "

list words = ["This", "Is", "A", "List"];

list entries = ["A list may contain many types of values such as", 2, 1.2, <0.4, 0.8, 1.6>];

vector vec_2 = <1,6,2>; //Generally used for position as xyz, but can be used to store 3 numbers to be parsed out later

rotation _rot = <1,2,3,4>; //Can also be used to store 4 numbers to be parsed out later

On/Off Example Using States

default

{

state_entry()

{

llSay(0, "turning on!");

llSetColor(<1.0, 1.0, 1.0>, ALL_SIDES); }

touch_start(integer total_number)

{

state off; // sets the script to a new "state" and starts running "state off"

}

}

state off

{

state_entry()

{

llSay(0, "turning off!");

llSetColor(<0.0, 0.0, 0.0>, ALL_SIDES);

}

touch_start(integer total_number)

{

state default;

}

}

If you click, it changes the state and changes the color

Use If /else.default{

state_entry(){

llSay(0, "Hello, Avatar!");

}

touch_start(integer total_number){

if (llDetectedKey(0) == llGetOwner()){

llSay(0, "Owner Touched.");

}

else{

llSay(0, "Someone Else Touched.");

}

}

}

If the Owner touch, it says “Owner Touched.”Else it says “Someone Else Touched”

Obj-to-Obj communication Sender

default

{

state_entry()

{

}

touch_start(integer total_number)

{

llWhisper(5, "SayOne");

}

}

Receiver

default

{

state_entry()

{

llListen(5,"","","");

}

listen(integer channel,string name, key id, string message)

{

if(message == "SayOne")

{

llSay(0, "One");

}

}

• Object 1 sends a command “SayOne” through the channel 5.

• Object 2 listens to the channel 5, and whenever it receives the message “SayOne”, It says “One”.

Use PHPkey requestid;

default

{

state_entry(){}

touch_start(integer total_number){

requestid = llHTTPRequest("http://.../a.php?ids=a", [HTTP_METHOD,"GET"],"");

}

http_response(key request_id, integer status, list metadata, string body){

if (request_id == requestid{

llOwnerSay(body);

}

}

}Send http request to a certain php file and receives the response

If you wanna program in C#OpenMetaverse foundation

provides a C# library to directly connect to the SL

http://openmetaverse.org/

Useful LinksList of the built-in functions:

◦http://lslwiki.net/lslwiki/wakka.php?wakka=functions

LSL tutorials◦http://wiki.secondlife.com/wiki/LSL_T

utorial

top related