Navigation

    CreatiCode Scratch Forum

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

    Rudimentary clone targeting system

    General Discussion
    2
    9
    311
    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.
    • SirBots
      SirBots last edited by

      So, I have come up with some code which (I think) would aim/target any clone of your choice, albeit not targeting the closest clone.

      So, each clone that you want your AI (or Sprite) to target, must have their x and y coordinates recorded in separate lists (Done for individual x and y variables for more versatility) Then, when instructed, (for example a tank fighting other tanks), it would pick a random list number. This number will be referred to as the “Clone Target Variable” This number will be used to pick the x and y for the AI to point at. (For example, if the CTV is 5, then it would pick row 5 of both lists, and it would be plugged in accordingly).

      Then, this tank, would then fire at the said coordinates that was plugged in from the listing, then repeats when it gets ready to fire again.

      I might use this for the near future for the bots in WOC, but this is being put to testing for the Airships to give them some type of use beyond just hiding bots underneath it.

      Your local coder who is working around the clock to make sure great games are made

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

        @sirbots

        Your idea sounds reasonable.

        One issue you might want to consider is how to make sure your clones are shooting at different targets, since when you let each of your clone randomly select a target, 2 of them may select the same target.

        One solution to this is to let the original sprite generate a random but none-repeating list, then each clone of yours can just look at this list for which target to attach, For example, if you have 5 clones and the enemy also have 5 clones, you can easily populate the list this way:

        b62ddd60-6d0b-4613-9a18-5cd7c7db2eda-image.png

        SirBots 1 Reply Last reply Reply Quote 0
        • SirBots
          SirBots @info-creaticode last edited by

          @info-creaticode So, lets say I have a 32v32 WOC match, say a random number from that list (32 players on enemy team), and it picks a number. Would it take the x and y of whatever bot has the same clone id number as what the randomize picked on the x and y lists?

          (If you played World of Conquest, then that should help provided you know how the ai works in the game)

          Your local coder who is working around the clock to make sure great games are made

          info-creaticode 1 Reply Last reply Reply Quote 0
          • info-creaticode
            CreatiCode @SirBots last edited by

            @sirbots

            No, your bots still need to look at the x/y lists to get the target’s position. This “id list” only serves to make sure your bots are targeting different targets.

            SirBots 2 Replies Last reply Reply Quote 0
            • SirBots
              SirBots @info-creaticode last edited by SirBots

              @info-creaticode I understand that. The ID list ensures that it has a different target every time it attacks its previous target,

              Now, how could I get them to calculate which target in both lists is the closest to aforementioned bot.

              From what I am aware of, triangulation is one of the methods, but I don’t know how to set it up.

              Your local coder who is working around the clock to make sure great games are made

              1 Reply Last reply Reply Quote 0
              • SirBots
                SirBots @info-creaticode last edited by

                @info-creaticode So, like this (targeting selected target)

                Screenshot 2025-02-05 1.53.10 PM.png

                Your local coder who is working around the clock to make sure great games are made

                info-creaticode 1 Reply Last reply Reply Quote 0
                • info-creaticode
                  CreatiCode @SirBots last edited by

                  @sirbots

                  You still need to do a linear search. For each of your bot, go through each target bot, calculate the distance to that target, and then keep track of which target is the closest.

                  SirBots 1 Reply Last reply Reply Quote 0
                  • SirBots
                    SirBots @info-creaticode last edited by SirBots

                    @info-creaticode What would be the script to calculate that?

                    In simpler terms, how to see which one within a set parameter is closer that another bot if they are in range to be detected

                    Your local coder who is working around the clock to make sure great games are made

                    info-creaticode 1 Reply Last reply Reply Quote 0
                    • info-creaticode
                      CreatiCode @SirBots last edited by

                      @sirbots

                      Check out this example program:

                      play.creaticode.com/projects/67a3c43978886c154e0b60af

                      Note that its code is written by our AI assistant XO, when it is given the following request:

                      I have 2 lists of x and y positions of targets, and I need to search among them to find which one is closest to this sprite. Use 2D distance.
                      

                      For this kind of small coding questions, we strongly recommend you to ask XO to get started. All you need is to clearly describe your needs.

                      If you are new to working with XO, you can try to use the “TIRE” method for prompting it: https://www.forum.creaticode.com/topic/1785/ai-the-t-i-r-e-prompting-method-difficulty-3

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