How do I create an AI that avoids obstacles

0 favourites
  • 4 posts
From the Asset Store
Fully commented source code/event sheet & sprites to create a space shooter game
  • Hello fellas,

    How can I program an AI that can avoid obstacles and try to score using different angle options, e.g. Billiards game.

    The AI on its turn should analyze and consider (between all the balls on its way) if there's any possible way or angle to shoot the ball and score, if not, to shoot it (with a proportional force) in a direction which can place the ball closer to the goal.

    I appreciate in advance any help, once again, thanks!

  • Bumping this thread. (If by any chance there's already a post -I could have missed- on the forums concerning to this topic, please let me know)

    Thanks in advance!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • There isn't much in C2 that is specific to this problem, you could look at answers on SO for ideas: http://stackoverflow.com/questions/2799 ... illiard-ai

    With some maths you can work out some shot angles to try, e.g. hitting off the wall to hit the target ball if there is something in the way. How do you tell if there's something in the way? You can use the algorithm for the distance from a point to a line segment to see if it is less than the radius of the two balls added together to see if it is 'in the way'. Use it to check against every other ball on the table and if none are in the way then it's a clear shot.

    If you're using Physics behaviors, I'm not sure if you can predict the outcome of a shot meaningfully. However, for an OK AI you don't need to be perfect. Trace angles and use geometry/physics to get an approximation of what will happen and use that to score the outcome of a shot. http://i.ytimg.com/vi/QXsfwLFX4iI/maxresdefault.jpg shows a kind of example of what you have to take into account: where the cue ball will hit another ball, and the angles of both those balls afterwards.

    In short, I don't think there's an easy way.

  • Hi tgfcoder,

    Sorry for the delay on my response. I'll take a look at your links, and get some inspiration for the code I need. I know this is not an easy task, but very challenging.

    I must say I'm looking forward to develop the code for this kind of AI!

    Thanks a lot mate.

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