Choose between a range of angles

Get help using Construct 2

Post » Wed Oct 07, 2015 2:35 pm

An AI player search for spaces between obstacles to shoot at, looking 360 degrees (step 2 degrees) around and then generating the map bellow, which have been stored in an array. So the columns represent the range of the angles that he found.

Image

This is the possible angles that an AI can choose from to shoot avoiding the obstacles. I wisht it could choose angles preferably between 270 <=> 90 degrees, if it is possible. And that the choosen angle may be the middle ones.

Ex.:
- In column 0, he should pick 34 or 36 degrees
- The column 1 did not met the 270 <=> 90 degrees condition, so it is ignored for now (until it don't have other option)
- In column 2, he should pick 212 or 214 degrees

According to this example, it will remain with the (34) or (36) and (212) or (214), which he should pick one of them randomly and finally shoot in that angle.

I've tried to figure out a code for this, but without success. May someone please can help me with that?

Thanks!
B
14
S
5
Posts: 110
Reputation: 1,338

Post » Wed Oct 07, 2015 3:37 pm

I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Wed Oct 07, 2015 5:29 pm

Thank you very much LittleStain,

I've noticed that the column 2 is also to be ignored, as it isn't between the priority range 270 <=> 90, sry for that. But anyways, it is working as it supposed to! You're awsome! I just have to make little adjustments to it.

In the capx you've sent me, there is only two columns on the array, but if there is more and one of them should be rejected as it does not met the 270<=>90 degrees? How can i select just the "right" columns?

I do not want to ask too much of you. You've already did an immense contribution, but if you may still help me with this, it will be very nice.

Thank you again!
Last edited by artbava on Wed Oct 07, 2015 6:25 pm, edited 5 times in total.
B
14
S
5
Posts: 110
Reputation: 1,338

Post » Wed Oct 07, 2015 6:15 pm

I guess you could loop over the array and remove all values that are between 90 and 270..
Or perhaps this could be done much better while creating the array, depending on how you have your events set up..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Wed Oct 07, 2015 6:27 pm

Ok, i'll try. Sry if i didn't fully understand what you've done (there is 3 columns not 2 as i've said :oops: ). I'm trying...lol! And i will also try to filter the angles while creating the array. Thanks again!!
B
14
S
5
Posts: 110
Reputation: 1,338


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 28 guests