Choose between a range of angles

0 favourites
  • 5 posts
  • 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.

    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!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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!

  • 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..

  • 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 ). I'm trying...lol! And i will also try to filter the angles while creating the array. Thanks again!!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)