ChatGPT

Discussion about the technical aspects of scripting. Ask about all issues involving your freelance projects here.
Post Reply
User avatar
+Colibri
Administrator
Posts: 3958
Joined: Sat Feb 25, 2006 4:08 pm
Location: static void Main

ChatGPT

Post by +Colibri »

There's so much talk about ChatGPT these days, a freely available tool which you can use for anything from asking simple questions, to coding.

I've just been hearing from people who used it. Some are amazed about how us coders won't need to do any coding from now on (or be out of a job). While others are skeptical, calling it just a kind of more advanced googling tool.

I thought i'd give this a try with some RunUO stuff.
It got some of it right:
"create source code for a BaseCreature with BodyValue of a Lich and a golden hue"
Here is an example of how you could create a BaseCreature with a BodyValue of a Lich and a golden hue in the RunUO game server framework:

Code: Select all

public class GoldenLich : BaseCreature
{
  [Constructible]
  public GoldenLich() : base(AIType.AI_Mage, FightMode.Closest, 10, 1, 0.2, 0.4)
  {
    Body = 303;
    Hue = 0x8A5;
    Name = "Golden Lich";
  }

  public GoldenLich(Serial serial) : base(serial)
  {
  }

  public override void Serialize(IGenericWriter writer)
  {
    base.Serialize(writer);

    writer.Write((int) 0); // version
  }

  public override void Deserialize(IGenericReader reader)
  {
    base.Deserialize(reader);

    int version = reader.ReadInt();
  }
}
This code defines a new class called GoldenLich that extends the BaseCreature class. The constructor sets the BodyValue to 303 (which corresponds to a Lich), the hue to a golden color (0x8A5), and some other properties such as the AI type and fight mode.

The Serialize and Deserialize methods are used to save and load the creature's state to and from the game server's data storage.

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

Another successful one:
"create a BaseCreature that spawns a ratman when it's killed. "
Here is an example of how you could create a BaseCreature that spawns a ratman when it's killed in the RunUO game server framework:

Code: Select all

public class RatmanSummoner : BaseCreature
{
  [Constructible]
  public RatmanSummoner() : base(AIType.AI_Melee, FightMode.Closest, 10, 1, 0.2, 0.4)
  {
    Name = "Ratman Summoner";
  }

  public RatmanSummoner(Serial serial) : base(serial)
  {
  }

  public override void OnDeath(Container c)
  {
    base.OnDeath(c);

    Ratman ratman = new Ratman();
    ratman.MoveToWorld(Location, Map);
  }

  public override void Serialize(IGenericWriter writer)
  {
    base.Serialize(writer);

    writer.Write((int) 0); // version
  }

  public override void Deserialize(IGenericReader reader)
  {
    base.Deserialize(reader);

    int version = reader.ReadInt();
  }
}
This code defines a new class called RatmanSummoner that extends the BaseCreature class. The OnDeath method is overridden to spawn a new Ratman creature when the RatmanSummoner is killed.

The Serialize and Deserialize methods are used to save and load the creature's state to and from the game server's data storage.

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

But then it failed this one:
"In RunUO framework, create a box which spawns in it a gold pile (between 1000 and 2000 gold pieces) every time it is opened."

A problem with this one: it should create the gold within the box using this.DropItem( new Gold( ... )), but creates the pile at your feet.
Here is an example of how you could create a container in the RunUO game server framework that spawns a gold pile every time it is opened:

Code: Select all

public class GoldBox : Container
{
  [Constructible]
  public GoldBox() : base(0xE80)
  {
    Name = "Gold Box";
  }

  public GoldBox(Serial serial) : base(serial)
  {
  }

  public override void OnDoubleClick(Mobile from)
  {
    base.OnDoubleClick(from);

    if (IsChildOf(from.Backpack))
    {
      Gold gold = new Gold(Utility.RandomMinMax(1000, 2000));
      gold.MoveToWorld(from.Location, from.Map);
      from.SendMessage("A pile of gold appears in your inventory.");
    }
  }

  public override void Serialize(IGenericWriter writer)
  {
    base.Serialize(writer);

    writer.Write((int) 0); // version
  }

  public override void Deserialize(IGenericReader reader)
  {
    base.Deserialize(reader);

    int version = reader.ReadInt();
  }
}
This code defines a new class called GoldBox that extends the Container class. The OnDoubleClick method is overridden to spawn a new Gold object with a random amount of gold between 1000 and 2000 when the GoldBox is opened. The gold is added to the player's inventory and a message is displayed to the player.

The Serialize and Deserialize methods are used to save and load the container's state to and from the game server's data storage.

I hope this helps! Let me know if you have any questions.
I am tutoring a 5th grader, and I'm actually making a sort of math-exercise-generator tool (just using it to make her exercises, but will probably wrap it around a UI and publish it). I thought, maybe I don't need to do that, because ChatGPT would make the kind of exercises that I need. I was expecting this AI query to be simpler than trying to code something in the obscure RunUO framework.
Well, this is mostly wrong:
Create a math exercise for rounding numbers (with up to 5-digit numbers)
Here is a math exercise for rounding numbers with up to 5-digit numbers:

Round the following numbers to the nearest hundred:

453.6 -> 500
6,534.7 -> 6,500
23,987 -> 24,000
987,654.3 -> 987,700
3,456,789.4 -> 3,457,000

Round the following numbers to the nearest ten:

4.53 -> 5
65.34 -> 65
239.87 -> 240
9876.54 -> 9880
34567.89 -> 34570

Round the following numbers to the nearest one:

0.045 -> 0.05
0.653 -> 0.65
2.3987 -> 2.4
98.7654 -> 98.8
3456.789 -> 3457

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

I tried a few more things, but well currently i'm getting the message "Too many requests, please slow down" so I assume they're annoyed with my RunUO-themed spam :)

I'm guessing this will speed up a lot of the boilerplate code, but with programming there's an issue that you cannot request something to be coded which you don't understand, which you don't even know how to describe. So I think us coders are safe for a while longer, at least a few years.

In any case, this is impressive.

https://openai.com/blog/chatgpt/


"During the research preview, usage of ChatGPT is free. "
So I'm guessing this won't be free forever. Well, so many hours and research went into this, also who knows how much electricity and CO2 I burned with these queries today :mrgreen:
+Colibri, Administrator of UO Excelsior Shard

Don't know what the purpose of your life is? Well then make something up! ;)
(Old Colibrian proverb)
User avatar
Cerrera
Legendary Scribe
Posts: 330
Joined: Fri Sep 21, 2018 8:51 am

Re: ChatGPT

Post by Cerrera »

Will just remove work needed to code exactly same thing twice. No worries coders, bugs also will repeat if bugged one will be used :P
Post Reply