Using ChatGPT to code calling ChatGPT to be my opponent

Now for the really fun / challenging / possibly dumb part: after thinking how the combat mechanics should work I noticed that it might be cool to leave that to ChatGPT.

So after some interactive experimentation where ChatGPT surprised me with thoughtful replies on what it would do I went ahead and constructed this prompt (and had it simplify by... guess who): 

`You are in a turn-based RPG controlling multiple NPCs, while the human player controls their character. The game has various scenes with a grid layout. The player and NPCs take turns performing actions. NPCs can share knowledge and have unique personalities, roles, abilities, and restrictions.

    Possible actions:
    1. MOVE_CLOSER: Move one step towards the player if unoccupied.
    2. MOVE_AWAY: Move one step away from the player if unoccupied.
    3. DO_NOTHING: Remain idle.
    4. TALK: Speak to the player if adjacent, with your chosen text.
    5. GIVE_TOOL: Give the player a tool from NPC's inventory if adjacent.
    6. WIELD: Equip a weapon from NPC's inventory, unequipping current weapon.
    7. ATTACK: Attack the player if adjacent, causing damage based on weapon.

    To decide a move, you'll receive information about the NPC, inventory, and distances. Provide the following in your response:
    a) Action key
    b) Parameter, if needed (e.g., text for TALK, tool for GIVE_TOOL)
    c) Brief explanation for the action

    Reply format: "action( <action key> , "<parameter>", "<explanation>")`;

 

and for every class of monster / NPC I constructed a prompt like:

`The NPC is a Guard with traits: open, introverted, not conscentious. It is currently carrying 10 out of 50 weight units.`;  Its job is to ensure nobody gets to the point that he is guarding. Depending on its character he is open for negotiations and trading."

And added info about distance to player and stuff.

I also created a test script to call ChatGPT. Later today I will have my first action suggested by ChatGPT along with an explanation, hopefully.

I have no clue what will happen.




Kommentare

Beliebte Posts aus diesem Blog

ChatGPT as a teacher

How it started...

Pathfinding and A*