Themabewertung:
  • 0 Bewertung(en) - 0 im Durchschnitt
  • 1
  • 2
  • 3
  • 4
  • 5
Scripten in der künstlichen Intelligenz
#1
Es gibt eine Webseite, wo zu Forschungszwecken zwei zufällig ausgewählte künstliche Intelligenzen anonym gegeneinander antreten. Danach soll man bewerten, welche Antwort "besser" war.

Was also liegt näher als mal zu fragen: "Write a door script for OpenSim."

A: Kurz und knackig, ein Quader als "Tür" wird vom Script gleich mit erzeugt, naja.

Code:
Here is a simple door script for OpenSim that you can use in Second Life or other compatible virtual worlds. This script will open and close the door when a user clicks on it.

To use this script, create a new primitive object in OpenSim (such as a box), and then open the object's contents window and paste the script into the "Scripts" tab.

default
{
    state_entry()
    {
        llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_BOX]);
        llSetLinkPrimitiveParamsFast(LINK_SET_FULLBRIGHT,[1.0,1.0,1.0,1.0]);
        llSetLinkPrimitiveParamsFast(LINK_SET_COLOR,<1.0,0.0,0.0>);
        llSetLinkPrimitiveParamsFast(LINK_SET_ALPHA,[0.0,0.0]);
        llSetLinkPrimitiveParamsFast(LINK_SET_ROTATION,<0.0,0.0,0.0,1.0>);
        llSetLinkPrimitiveParamsFast(LINK_SET_POSITION,<0.0,0.0,0.0>);
        llSetLinkPrimitiveParamsFast(LINK_SET_SCALE,<0.5,2.0,0.5>);
        llSetLinkPrimitiveParamsFast(LINK_SET_KEY,["door", ALL_SIDES, 0.0, 0.0]);
    }

    touch_start(integer total_number)
    {
        key id = llDetectedKey(0);
        list detects = llDetectedTouchST(id);
        integer face = (integer)llList2Integer(detects, 0);
        vector offset = llList2Vector(detects, 1);

        if (face == 0 || face == 2)
        {
            // Open door
            llSetLinkPrimitiveParamsFast(LINK_SET_ROTATION,<0.0,90.0,0.0,1.0>);
        }
        else if (face == 1 || face == 3)
        {
            // Close door
            llSetLinkPrimitiveParamsFast(LINK_SET_ROTATION,<0.0,0.0,0.0,1.0>);
        }
    }
}

This script will create a red box that functions as a door. When the user clicks on one of the sides of the box, the door will open or close, depending on the side that was clicked.

You can customize the appearance of the door by changing the values in the llSetLinkPrimitiveParamsFast functions. For example, you can change the size of the door by adjusting the values in the llSetLinkPrimitiveParamsFast(LINK_SET_SCALE,...) function. You can also change the color of the door by adjusting the values in the llSetLinkPrimitiveParamsFast(LINK_SET_COLOR,...) function.

I hope this helps! Let me know if you have any questions.

B: Der Klassiker.

Code:
Here's a basic door script for OpenSim in LSL (Linden Scripting Language):

// Door script for OpenSim

// Variables
integer DOOR_OPEN = FALSE;
rotation rot_init;

default
{
    state_entry()
    {
        rot_init = llGetRot();
    }

    touch_start(integer total_number)
    {
        if (!DOOR_OPEN)
        {
            llRotateAroundAxis(llEuler2Rot(<0.0, 0.0, PI/2>), <0.0, 0.0, 1.0>, rot_init, 1.0);
            DOOR_OPEN = TRUE;
        }
        else
        {
            llRotateAroundAxis(llEuler2Rot(<0.0, 0.0, -PI/2>), <0.0, 0.0, 1.0>, rot_init, 1.0);
            DOOR_OPEN = FALSE;
        }
    }
}

Here's how it works:

    The script starts by declaring a boolean variable DOOR_OPEN to keep track of the door's state (open or closed) and a rotation variable rot_init to store the initial rotation of the door.

    In the state_entry() event, the script stores the initial rotation of the door prim in rot_init.

    The touch_start() event is triggered when the door prim is touched. If DOOR_OPEN is FALSE (i.e., the door is closed), the script rotates the door prim 90 degrees around its local Z-axis using the llRotateAroundAxis() function, and sets DOOR_OPEN to TRUE.

    If DOOR_OPEN is TRUE (i.e., the door is open), the script rotates the door prim -90 degrees around its local Z-axis, and sets DOOR_OPEN to FALSE.

    The llEuler2Rot() function is used to convert Euler angles (in radians) to a rotation quaternion, which is required by the llRotateAroundAxis() function.

This script assumes that the door prim is initially positioned and rotated correctly. You may need to adjust the rotation angles and axis based on your specific setup.

Note that this is a basic example, and you may want to add additional features like sound effects, animations, access control, and more, depending on your requirements.

Beide Scripte mit Erklärtext dabei, ich vote mal B. Big Grin
(Auflösung: Die KI Variante A war "mixtral-8x7b-instruct-v0.1", und B war "claude-3-sonnet-20240229".)

Also da geht was, den Code für bekannte Probleme irgendwo reinklopfen brauchen dann wohl in ein paar Jahren keine Menschen mehr machen. Huh

Und irgendwann fragen uns die Captchas, ob wir auch wirklich Roboter sind. Rolleyes

   
[-] The following 4 users say Thank You to Mareta Dagostino for this post:
  • Dorena Verne, Leora Jacobus, Manfred Aabye, Pius Noel
Zitieren


Nachrichten in diesem Thema
Scripten in der künstlichen Intelligenz - von Mareta Dagostino - 15.03.2024, 14:14

Gehe zu:


Benutzer, die gerade dieses Thema anschauen: 1 Gast/Gäste