Basically I need the Marine to face the "safest" place, so that later the angle that was used to make the Marine face this position will be very very useful to implement a kiting bot. The factors that will affect where the Marine is facing:
- Number of Zergling(s)
- Position of Zergling(s)
- Distance between Zergling(s) and the Marine (ignore this as a start)
Hi, Trieva, thanks for your response. Unfortunately Im not too good at using this map editor. Actually I was doing this earlier and I sort of gave up very quickly as I didn't know how to continue. (I use GUI btw)
This only useful action I found was "Make Unit Face Angle". It makes a unit face an angle that you specify.
A function I found called "Facing angle of unit" gets the facing angle (in a real) of a unit.
What I found interesting was the "angle mechanics". In the terrain editor to change the rotation of any unit you specify an angle between 0 and 360 degrees. The function "Facing angle of unit", however, returns a value of between -180 and 180 degrees. Figured out using a simple trigger:
And the result is a marine looking at the left and gradually turning in anti-clockwise direction. Here's a simple visualisation I made from what I understand:
Here is the trigger Change Marine Angle I made but it doesn't work.
Basically everything is already working correctly and well set, just that I don't know what to set the variable "angle" as and I'm trying to figure it out. Just need to think of some mathematical thing to achieve this...
By the way, this is the "Handle Marine Angle" action definition:
That's all I have. What I'm thinking is that the variable "nearby units angles" is completely useless and probably won't have any use in calculating the variable "angle". I think what I really need is a way to find the zergling's position relative to the marine in terms of angle. Like I need to find a way to get the number 0 when a Zergling is directly on the right of the Marine.
For the most dangerous facing you could use "make unit face point" and for the point "center of unit group". The unit group could be all nearby enemy units (units in region with alliance to player).
But now that I re-read the post, it looks like you want the least dangerous facing, so the opposite of above. It's been so long since I've taken geometry... Is there a good way to get the opposite of an angle?
Hi all, thanks for your suggestions. I sort of figured out how to make it work for 1 zergling.
I found a very useful function "Angle between points", which returns the angle from point 1 to point 2 as a real value in degrees. I changed the trigger "Change Marine Angle" accordingly to get this:
It seems like it doesn't make sense, especially this line "Variable - Set angle = (Angle from (Position of (Picked unit)) to (Position of Marine))". Why am I setting the angle between the Zergling and the Marine as the angle for the Marine to turn?
Well, this is something I found that was interesting when I use the Angle between points function with point 1 as the position of Zergling and point 2 as the position of the marine:
Basically the Angle Between Points function sort of returns the opposite angle as compared to Make Unit Face Angle. So with this I sort of found the opposite of an angle. So the map works, but only with 1 zergling.
I don't know how to move on for more than 1 zergling, but I hope you guys will continue to give me advice. Thanks.
(See my post above for the explanation for the "(Angle from (Position of (Picked unit)) to (Position of Marine))" part.)
This is the compilation of my Marine's behaviour:
As you can see, the Marine is acting very strangely when there are 3 Zerglings, but perfect when there are 2 Zerglings. Would appreciate it if someone can find a solution to the Marine's strange behaviour when there are 3 Zerlings.
I'm not sure if this is better than the previous code (see previous post). It seems less glitchy when there are more than 2 zerglings but there are still a couple of glitches to fix. In your opinion, which code is preferred, the code in this post, or the code in the previous post?
The unit custom value was unnecessary, I thought that I would need it in future.
Basically the zerglings' opposite angles are the safe angles for each individual zergling. So I divide by the number of zerglings to get the average of these safe angles, and the marine will face this average angle (which is, in most cases, the safest angle)
Maybe it's easier to see visually:
By the way, by identifying the safe angle using my method, I came up with this little marine bot. Not the best one though, but still quite impressive. Attached below:
After thinking about it for a while, I think I need to change the equation to something else that is more accurate and reliable, especially for more than 2 zerglings. For more than 2 zerglings, there are many unexpected things that can happen. For example:
That's just one example. There are many other glitches when there are more than 2 nearby zerglings.
EDIT:
I just saw your new post. I think that changing the equation is still the way to go.
Could you elaborate on "divide the angles around the marine to a certain number of equal spaces and see which zerglings fall into these spaces."? I don't quite understand it, maybe a pic?
Will work on it maybe tomorrow. I made a video featuring my marine bot ()
The strange thing that happens everytime I run 15 Marines vs 50 Zerglings is that sometimes the Marines win by a narrow margin, sometimes the Zerglings win by a narrow margin, and a few times, the Zerglings win very one-sidedly. So that's a bit odd.
What if you did a loop, 0 to 359, and if you draw a line out from the marine at that angle and there is no Zergling at that location, increment a temporary counter. You will then simply find the maximum value of consecutive "safe angles" and use the middle degree angle as the safe angle.
Sorry, can't open up the editor at the moment to write this out, but it would solve the proper angle for all of the pictured Zerglings above.
For example, below the safe angle would be 37.5 degrees because there were 107 consecutive "safe angles" where there were no Zerglings (and I know that number isn't exact, because more than just one degree line would intersect with the Zergling), and half of that is 53.5, but you'd have to subtract 16 from that because the "safe angle" started at 344 and ended at 91, and voila, 37.5 degrees, now the marine should be facing the safest angle.
If you are concerned this is too taxing (which it might be) you could always increase the step, just make sure you don't increase it to the point that you miss some Zerglings!
Thanks for the advice. I know how to find the angles of the zerglings (btw, angles are from -180 to 180, not 0 to 360), I don't think I need a loop for that. But indeed it's a good idea to find the largest difference.
I'm trying to do it noww, but I'm not exactly sure how.
Might be able to combine my idea with some of the others. Since you can't make non circle/rectangular regions, you might be able to use negative regions to check the different areas around the marine, and see which has the least enemies.
Does anyone know how to make something like the angle test?
EDIT:
The video's angle test seems a little vague, I think this one seems more in-depth:
Also see this post: http://www.sc2mapster.com/forums/development/triggers/79964-dargleins-marine-ai/#p3 It shows what I have tried and found out.
Basically I need the Marine to face the "safest" place, so that later the angle that was used to make the Marine face this position will be very very useful to implement a kiting bot. The factors that will affect where the Marine is facing:
- Number of Zergling(s)
- Position of Zergling(s)
- Distance between Zergling(s) and the Marine (ignore this as a start)
- Terrain ( also ignore this as a start)
@Trieva: Go
Hi, Trieva, thanks for your response. Unfortunately Im not too good at using this map editor. Actually I was doing this earlier and I sort of gave up very quickly as I didn't know how to continue. (I use GUI btw)
This only useful action I found was "Make Unit Face Angle". It makes a unit face an angle that you specify.
A function I found called "Facing angle of unit" gets the facing angle (in a real) of a unit.
What I found interesting was the "angle mechanics". In the terrain editor to change the rotation of any unit you specify an angle between 0 and 360 degrees. The function "Facing angle of unit", however, returns a value of between -180 and 180 degrees. Figured out using a simple trigger:
And the result is a marine looking at the left and gradually turning in anti-clockwise direction. Here's a simple visualisation I made from what I understand:
Here is the trigger Change Marine Angle I made but it doesn't work.
Basically everything is already working correctly and well set, just that I don't know what to set the variable "angle" as and I'm trying to figure it out. Just need to think of some mathematical thing to achieve this...
By the way, this is the "Handle Marine Angle" action definition:
That's all I have. What I'm thinking is that the variable "nearby units angles" is completely useless and probably won't have any use in calculating the variable "angle". I think what I really need is a way to find the zergling's position relative to the marine in terms of angle. Like I need to find a way to get the number 0 when a Zergling is directly on the right of the Marine.
I hope you can help me :)
For the most dangerous facing you could use "make unit face point" and for the point "center of unit group". The unit group could be all nearby enemy units (units in region with alliance to player).
But now that I re-read the post, it looks like you want the least dangerous facing, so the opposite of above. It's been so long since I've taken geometry... Is there a good way to get the opposite of an angle?
Hi all, thanks for your suggestions. I sort of figured out how to make it work for 1 zergling.
I found a very useful function "Angle between points", which returns the angle from point 1 to point 2 as a real value in degrees. I changed the trigger "Change Marine Angle" accordingly to get this:
It seems like it doesn't make sense, especially this line "Variable - Set angle = (Angle from (Position of (Picked unit)) to (Position of Marine))". Why am I setting the angle between the Zergling and the Marine as the angle for the Marine to turn?
Well, this is something I found that was interesting when I use the Angle between points function with point 1 as the position of Zergling and point 2 as the position of the marine:
Basically the Angle Between Points function sort of returns the opposite angle as compared to Make Unit Face Angle. So with this I sort of found the opposite of an angle. So the map works, but only with 1 zergling.
I don't know how to move on for more than 1 zergling, but I hope you guys will continue to give me advice. Thanks.
I modified my trigger and this works for 2 zerglings, with strange behaviour for 3 / 4 zerglings. This is so awesome :)
This is the full trigger now:
(See my post above for the explanation for the "(Angle from (Position of (Picked unit)) to (Position of Marine))" part.)
This is the compilation of my Marine's behaviour:
As you can see, the Marine is acting very strangely when there are 3 Zerglings, but perfect when there are 2 Zerglings. Would appreciate it if someone can find a solution to the Marine's strange behaviour when there are 3 Zerlings.
Sorry for the spam :D but I found the most elegant method that is the least "glitchy". Here are the triggers:
Change Marine Angle Experimental:
And a function Get Opposite Angle:
I'm not sure if this is better than the previous code (see previous post). It seems less glitchy when there are more than 2 zerglings but there are still a couple of glitches to fix. In your opinion, which code is preferred, the code in this post, or the code in the previous post?
@Trieva: Go
The unit custom value was unnecessary, I thought that I would need it in future.
Basically the zerglings' opposite angles are the safe angles for each individual zergling. So I divide by the number of zerglings to get the average of these safe angles, and the marine will face this average angle (which is, in most cases, the safest angle)
Maybe it's easier to see visually:
By the way, by identifying the safe angle using my method, I came up with this little marine bot. Not the best one though, but still quite impressive. Attached below:
@Trieva: Go
After thinking about it for a while, I think I need to change the equation to something else that is more accurate and reliable, especially for more than 2 zerglings. For more than 2 zerglings, there are many unexpected things that can happen. For example:
That's just one example. There are many other glitches when there are more than 2 nearby zerglings.
EDIT:
I just saw your new post. I think that changing the equation is still the way to go.
Could you elaborate on "divide the angles around the marine to a certain number of equal spaces and see which zerglings fall into these spaces."? I don't quite understand it, maybe a pic?
@Trieva: Go
Sounds like a really cool idea, but I'm not sure if it's possible, or if I am able to implement such a thing using the editor.
How about something like this?
@Trieva: Go
Will work on it maybe tomorrow. I made a video featuring my marine bot ()
The strange thing that happens everytime I run 15 Marines vs 50 Zerglings is that sometimes the Marines win by a narrow margin, sometimes the Zerglings win by a narrow margin, and a few times, the Zerglings win very one-sidedly. So that's a bit odd.
@MaskedImposter: Go
Wow, actually, yours seems pretty good. I haven't found any bugs so far. Good job.
EDIT 1:
Oops, I just found a bug:
By the way, I had edited the map such that the Zerglings and the Marine all belong to me, makes it easier for testing.
Are there any other "better" ways to get the safe angle?
What if you did a loop, 0 to 359, and if you draw a line out from the marine at that angle and there is no Zergling at that location, increment a temporary counter. You will then simply find the maximum value of consecutive "safe angles" and use the middle degree angle as the safe angle.
Sorry, can't open up the editor at the moment to write this out, but it would solve the proper angle for all of the pictured Zerglings above.
For example, below the safe angle would be 37.5 degrees because there were 107 consecutive "safe angles" where there were no Zerglings (and I know that number isn't exact, because more than just one degree line would intersect with the Zergling), and half of that is 53.5, but you'd have to subtract 16 from that because the "safe angle" started at 344 and ended at 91, and voila, 37.5 degrees, now the marine should be facing the safest angle.
If you are concerned this is too taxing (which it might be) you could always increase the step, just make sure you don't increase it to the point that you miss some Zerglings!
@DaBernMon: Go
Thanks for the advice. I know how to find the angles of the zerglings (btw, angles are from -180 to 180, not 0 to 360), I don't think I need a loop for that. But indeed it's a good idea to find the largest difference.
I'm trying to do it noww, but I'm not exactly sure how.
EDIT: Well, I tried but it somehow didnt work
Might be able to combine my idea with some of the others. Since you can't make non circle/rectangular regions, you might be able to use negative regions to check the different areas around the marine, and see which has the least enemies.
@MaskedImposter: Go
I think your previous one (Angle from + Center of unit group) works the best. Check this out:
I think for a (sort of) kiting AI, that is good enough.
@Chris97Ong: Go
Aw poor banelings, I've created a monster! xP
@Chris97Ong: Go
That's awesome! Well done! How does it work when the Marines hit a boundary like a cliff edge or the edge of the map?
@DaBernMon: Go
It doesn't. Will be great if there's a workaround to solve this issue, but I'm not in desperate need of it though.