Posts

My game works! But doesn’t.

 Nowhere done yet, but the game loop that  Once Initialises game UI and sends initial prompt to remote ChatGPT 3.5 that explains its job controlling the NPCs Enables controls for player to do an action Processes player action Creates prompt describing the situation, the last player move, the reaction of the game to last GPT move suggestion Communicates with remote ChatGPT to get an action Process NPC action Works! 95% of the code is written by ChatGPT 4, and in working with it I got halfway den cent JS skills. Wouldn’t say I’m good but I understand many concepts now that I didn’t get before, particularly the “spontaneously return complex structures in a function/method”, the asynchronous stuff (basic) and the functional stuff (basic). But GPT 3.5 IS JUST SO DAMN STUPID. I was hoping for a mode in which it replies with wrong answers, and the game updates it with “that was wrong” and the next time it gets it right. Far from it. Will spend happy hours tuning my prompt. Probably will go fo

ChatGPT as a teacher

Bild
Today I came to the conclusion that without a good understanding of asynchronous programming in Javascript, I cannot hope to come up with a game that uses asynchronous events for all player interaction and other asynchronous events to talk to a remote ChatGPT for NPC actions. My code was a mess, and even more important, after 3 refactorings of my game.js class following ChatGPT's suggestions, my mind was a mess as well. And (see other posts) I don't think that handing ChatGPT the control over the overall concepts, design, architecture, is a good idea. So I asked it to explain asynchronous JS programming to me. And it did. Quite exceptionally. See, in normal life you can learn something like this in several ways: You can read a book. I actually have a good JS book. A very, very tedious affair. I have 30+ years of serious programming experience (not counting my "geek teenager programs the heck out of his Sharp MZ-80A with 48K RAM and 1K ROM" time here). A JS book is 95

Quite good for one hour...

Bild
With ChatGPT's help, today I created everything needed for chatting back and forth between human-controlled player and ChatGPT-controlled NPC. The human can click on a "chat" button which will unhide a text input field and a submit button, both nicely styled; clicking on the button again will hide it again. Another new section contains about 3 lines of scrollable chat from the NPCs.  I had to start a new session though; the long session I've been using for days now got extremely slow - the stuff I was typing appeared with something like one character per 3 seconds, while I was typing. No clue what was wrong; creating a new session made things fast again. Also, the new session was getting confused, mixing up names of HTML elements, forgetting what it had created etc.; this might be related with me getting confused a bit. The AI generated stuff so fast that I forgot a method it had generated. I then told it I need this function, it generated one that looked wrong (wrong

Pathfinding and A*

If I want my NPCs to move towards the player on a nxm grid, and the grid can contain trees that the NPC cannot pass, I need an algorithm that finds the shortest path to the player. I gave this as a problem to ChatGPT: In class level I would like to have a new method shortestPath that finds out the shortest path that an NPC on coordinate startX, startY has to take to reach coordinate endX, endY, avoiding any squares where the top levelObject cannot be traversed. The result should be a list of coordinates starting with startX, startY and ending with endX, endY where each coordinate can be reached horizontally, vertically or diagonally from the previous one. To which it responded with: This sounds like a pathfinding problem, which can be solved using various algorithms such as A*, Dijkstra's Algorithm, or Breadth-First Search. Since you want to allow diagonal movement as well, A* would be a good choice here. However, please note that implementing such algorithms in a complex env

Better prompt reveals massive differences between ChatGPT-3.5 and ChatGPT-4

After refining my prompt (in case you're interested you find it at the end of this blog entry), things are starting to look more bright. Embarassing moment: I told ChatGPT that there is a weapon lying around next to it, and also told it that this NPC wants to use tools like weapons, but I included neither an action to move closer to a tool nor to pick up a tool. Bummer. Added these and got these replies from ChatGPT: Prompt: The NPC is currently positioned 6 steps away from the player. The Player is not adjacent to the NPC. The NPC is a Fierce Warrior with traits: extraverted, conscientious. He is very eager to pick up new tools. He cautiously approaches the player. Depending on his character he attacks or chats. Sometimes he talks. He is generally not interested in giving away or receiving tools.. The NPC is currently carrying 0 out of 100 weight units. The closest tool is a weapon located 1 steps away. What is your response? Please provide action key, parameter if needed, and a b

Prompting gone horribly wrong

Now this went differently than expected. I was doing my best to create a prompt that is so clear that the AI knows it has to answer with one of the 8 actions the game will be able to interpret. But it's not a dumb "I do what you want" AI. It's ChatGPT (using 3.5 turbo because it's way cheaper than 4.0). My clever initial prompt to explain the session's rules (actually I had ChatGPT4.0 rework it for clarity and brevity): 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 te