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 Works RPI Demo of Eddie, The Four-Year-Old Avatar Chatting with an AI in Second Life Automated Avatars in Second Life AI patient in second life using scripted prim and challenge response Joshua 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 SL Tutorial of Linden Scripting Language Create an account 1. 2. 3. 4. Visit https://join.secondlife.com to create your account Send me the account so that I can register you to U of A. island Download and Install the Viewer Search U of A. island and teleport Learn how to control Walk Run Fly Control View + drag mouse Creating Objects Right click any place in the island to Edit Choose Create button Pick one shape and click any location where you want to place the prim at. Editing Object If 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 together Shift + click objects you want to link together Then, Ctrl + L to link If 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. FUNCTIONS Functions 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 box 10m 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 examples integer 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 off { { state_entry() state_entry() { { llSay(0, "turning on!"); llSay(0, "turning off!"); llSetColor(<1.0, 1.0, 1.0>, ALL_SIDES); llSetColor(<0.0, 0.0, 0.0>, ALL_SIDES); } } touch_start(integer total_number) { state off; // sets the script to a new "state" and starts running "state off" } } 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 PHP key 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 Links List of the built-in functions: ◦ http://lslwiki.net/lslwiki/wakka.php?wakka=fun ctions LSL tutorials ◦ http://wiki.secondlife.com/wiki/LSL_Tutorial