Navigation

    CreatiCode Scratch Forum

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • CreatiCode

    AI players?

    General Discussion
    5
    11
    572
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Black Cat
      Shrukin Longtail last edited by

      Would it be possible to make AI players in games like my Star Trek?

      ㅤㅤㅤㅤㅤㅤ (look in bio for random)
      ㅤㅤㅤㅤㅤㅤLook at my bio? Click the link… I'm lonely…

      Tyller_ jeffreyrb03-gmail 2 Replies Last reply Reply Quote 0
      • Tyller_
        Tyller_ Best Forum Helpers @Black Cat last edited by

        @mathew139616-10db496a Yes, if you want them to not just be hard coded you wouldn’t be able to because the neural networks in the editor require set data tables, so you can’t really train them with manual inputs and reward them accordingly

        <div component="post/signature" data-uid="255" class="post-signature">Check out my chat room project so you ppl can not use forums as chat rooms! https://play.creaticode.com/projects/66f2e1dcd1be43d82b886fbd?version=1 <p dir="auto">
        </div>

        1 Reply Last reply Reply Quote 0
        • jeffreyrb03-gmail
          JaecadeJnight Mod Helper @Black Cat last edited by

          @mathew139616-10db496a Tyller is right but here are some other solutions:

          • you could also use the ChatGPT blocks. Those can take a couple seconds though, and more processing power, so maybe not the best idea considering your game would be fast paced and you wouldn’t want to have to wait for the AI to give a response and then move or do whatever. This could work for a Pokemon-like or turn based fighting game though, where you make your move, the enemy gets hurt, and then you have to wait for them to choose their move.

          (with the method I was explaining) You may be wondering how would you just casually “get ChatGPT to move your NPC or an enemy”, and the thing is you can’t. But the thing is you could use them to make an “AI player” by making it give a sort of “code” as it’s response and then you’d make it move or do an action based on what code it gave. You would start off by giving the ChatGPT block a prompt like this:

          “You are controlling an AI enemy in my game. The player is moving towards you and shooting you. What are you going to do? Pick one of these options and respond with the corresponding letter in parentheses (for example, if you wanted to shoot the player, then respond with “s” and that only): shoot the player (s), dodge the player’s bullets (b), shoot the player with rockets (x), or enable the shield (e).”

          And then using if else blocks, you would check if ChatGPT’s result is either s, b, x, or e, and then making the “AI player” do different things based on what letter ChatGPT responded with.
          Also you would want to tell ChatGPT every time the player is doing something important or slightly significant, like if the player is moving closer to the AI, rotating around, shooting it, etc.
          And after that, you would continue the same chat so that it doesn’t forget what the player is doing and what it did as a response. This is also so that you can allow ChatGPT to be strategic, because so that it can realize patterns in what the player is doing and then adapt to it and respond with any of those letters.

          And that is how you’d basically utilize ChatGPT to control an AI character. It’s a bit complicated but it just would take a bit of blocks as well. But that’s better than having to reinvent the wheel and hardcode an algorithm that watches everything the player does and reacts to it (because there are a lot of possible things, so you’d have like a million if/else blocks!).

          If you want help making what I just said, I’m happy to make code for your specific case!

          #LLJW
          <span style="color:white;background-image:linear-gradient(to right, lightblue, navy)">My name is Jeff</span>

          info-creaticode H 2 Replies Last reply Reply Quote 1
          • Black Cat
            Shrukin Longtail last edited by

            That would help! Thank you!

            ㅤㅤㅤㅤㅤㅤ (look in bio for random)
            ㅤㅤㅤㅤㅤㅤLook at my bio? Click the link… I'm lonely…

            jeffreyrb03-gmail 1 Reply Last reply Reply Quote -2
            • jeffreyrb03-gmail
              JaecadeJnight Mod Helper @Black Cat last edited by

              @mathew139616-10db496a tell me if you want help coding something like that

              #LLJW
              <span style="color:white;background-image:linear-gradient(to right, lightblue, navy)">My name is Jeff</span>

              1 Reply Last reply Reply Quote 1
              • Black Cat
                Shrukin Longtail last edited by

                Ok, thank you! Also, how do you upvote a post?

                ㅤㅤㅤㅤㅤㅤ (look in bio for random)
                ㅤㅤㅤㅤㅤㅤLook at my bio? Click the link… I'm lonely…

                jeffreyrb03-gmail 1 Reply Last reply Reply Quote -2
                • jeffreyrb03-gmail
                  JaecadeJnight Mod Helper @Black Cat last edited by

                  @mathew139616-10db496a press the up arrow right near where it says “Quote”

                  #LLJW
                  <span style="color:white;background-image:linear-gradient(to right, lightblue, navy)">My name is Jeff</span>

                  1 Reply Last reply Reply Quote 1
                  • info-creaticode
                    CreatiCode @jeffreyrb03-gmail last edited by

                    @jeffreyrb03-gmail said in AI players?:

                    @mathew139616-10db496a Tyller is right but here are some other solutions:

                    • you could also use the ChatGPT blocks. Those can take a couple seconds though, and more processing power, so maybe not the best idea considering your game would be fast paced and you wouldn’t want to have to wait for the AI to give a response and then move or do whatever. This could work for a Pokemon-like or turn based fighting game though, where you make your move, the enemy gets hurt, and then you have to wait for them to choose their move.

                    (with the method I was explaining) You may be wondering how would you just casually “get ChatGPT to move your NPC or an enemy”, and the thing is you can’t. But the thing is you could use them to make an “AI player” by making it give a sort of “code” as it’s response and then you’d make it move or do an action based on what code it gave. You would start off by giving the ChatGPT block a prompt like this:

                    “You are controlling an AI enemy in my game. The player is moving towards you and shooting you. What are you going to do? Pick one of these options and respond with the corresponding letter in parentheses (for example, if you wanted to shoot the player, then respond with “s” and that only): shoot the player (s), dodge the player’s bullets (b), shoot the player with rockets (x), or enable the shield (e).”

                    And then using if else blocks, you would check if ChatGPT’s result is either s, b, x, or e, and then making the “AI player” do different things based on what letter ChatGPT responded with.
                    Also you would want to tell ChatGPT every time the player is doing something important or slightly significant, like if the player is moving closer to the AI, rotating around, shooting it, etc.
                    And after that, you would continue the same chat so that it doesn’t forget what the player is doing and what it did as a response. This is also so that you can allow ChatGPT to be strategic, because so that it can realize patterns in what the player is doing and then adapt to it and respond with any of those letters.

                    And that is how you’d basically utilize ChatGPT to control an AI character. It’s a bit complicated but it just would take a bit of blocks as well. But that’s better than having to reinvent the wheel and hardcode an algorithm that watches everything the player does and reacts to it (because there are a lot of possible things, so you’d have like a million if/else blocks!).

                    If you want help making what I just said, I’m happy to make code for your specific case!

                    Thanks for the input. However, I’d like to add that this may run into context window limit issue, since, as you explained, each iteration is a continuation of the previous chats, so it makes the chat history longer and longer, and soon this will run into the limit of context window. It will also cost a lot of money, though that is currently fully paid for by CreatiCode. Another potential issue is the respond speed, since it may take too long for ChatGPT’s response to come back to make the AI player take an action. Therefore, most of such AI players are still better controlled by more traditional rule-based logic than ChatGPT.

                    We would recommend using ChatGPT for strategy games that require the AI talk to the human players, such as this game:

                    https://www.forum.creaticode.com/topic/961/chatgpt-ai-who-s-the-spy-difficulty-3

                    jeffreyrb03-gmail 1 Reply Last reply Reply Quote 1
                    • jeffreyrb03-gmail
                      JaecadeJnight Mod Helper @info-creaticode last edited by

                      @info-creaticode that is very true, I did say though that it would take longer and more computing power but I didn’t even think of the costs, which is very important as well.

                      #LLJW
                      <span style="color:white;background-image:linear-gradient(to right, lightblue, navy)">My name is Jeff</span>

                      1 Reply Last reply Reply Quote 0
                      • H
                        hynesaveryy @jeffreyrb03-gmail last edited by hynes.averyy-8b125bb5

                        @jeffreyrb03-gmail This is an interesting approach to creating AI enemies in a game! I can see how using ChatGPT blocks could add some unpredictability to enemy behavior. The letter-code system is clever for simplifying input/output.
                        That said, I wonder about the response time issues you mentioned. Even a couple seconds delay could feel frustrating in many game types. The other challenge might be maintaining context over a long game session - LLMs sometimes “forget” earlier parts of conversations when they get lengthy.
                        I’ve been experimenting with something similar while using narrati.io for my game narrative development. While narrati is primarily for generating story content, I noticed its contextual memory could potentially be adapted for simple game AI behavior patterns too. I was drafting character personalities and reaction patterns, and realized these could translate to behavior rules for NPCs.
                        Maybe a hybrid approach could work? Use pre-defined behavior patterns (developed through story-oriented tools like narrati for quick reactions, but supplement with ChatGPT for more complex decision-making during natural pauses in gameplay? This way you get the best of both - responsive gameplay plus intelligent adaptation.
                        Would be curious to see what you end up building with this approach! The concept definitely has potential for creating more dynamic enemies than traditional hardcoded behavior trees.

                        jeffreyrb03-gmail 1 Reply Last reply Reply Quote 1
                        • jeffreyrb03-gmail
                          JaecadeJnight Mod Helper @hynes.averyy-8b125bb5 last edited by

                          @hynes-averyy-8b125bb5 It is quite annoying when they forget stuff during a lot conversation lol, that is true. Ill check out narrati and tell you what I think. Ive been experimenting with AI lately for different stuff (except its “art”) and I might make a project for this now not sure 🤔. Thank you for the response!

                          #LLJW
                          <span style="color:white;background-image:linear-gradient(to right, lightblue, navy)">My name is Jeff</span>

                          1 Reply Last reply Reply Quote 0
                          • First post
                            Last post