Rudimentary clone targeting system
-
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 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:
-
@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)
-
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.
-
@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.
-
@info-creaticode So, like this (targeting selected target)
-
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.
-
@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
-
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