Members - Reputation: 109
Posted 31 May 2012 - 07:12 AM
I'm stuck while developing an A.I.[Now don't back off saying that not my field just continue reading]
for Pool / Billiard type game
[well actually its called "Carrom"; Carrom = (Flat pieces)Pool / Billiard - rolling balls;]
Details[Plz do visit this link, & Open in new tab]
well any thought How to do it ?
Note to Moderator:
Sorry this been double post but the nature of question need experts from both fields...So please don't delete this.....Thank you.
Members - Reputation: 4730
Posted 31 May 2012 - 10:42 PM
Loop through every ball you need to hit in. (Solids or Stripes)
For each ball, check to see if there is a clear path to each pocket.
If there is a clear path, calculate where the q-ball needs to hit the ball in order to hit it into that pocket
Try to find a clear path from the q-ball to the ball in question allowing for a bounce or two off of the walls
If there is a clear path Make sure the q-ball doesn't go into a pocket, resulting in a scratch
Hopefully by looping through each of the balls and pockets like that you can come up with discrete shots that you can then score based on the following criteria
Does one of my balls go in?
Do I scratch?
If I hit a ball in, does the q-ball end up in a good place for my next shot (you may need to recursively evaluate shots)
If I do not hit the ball in, does the ball end up in a difficult place for the opposing player
How hard is the shot? (difficulty could be based on distance, sharper angles, and bouncing off of the wall)
After scoring each shot, pick the shot with the best score then have the computer execute that shot only applying a slight error in the angle and power of the shot. The amount of error applied to the shot could based on the difficulty of the player and the difficulty of the shot.
Just a few of my thoughts on the AI.
A tricky part of the AI would be calculating shots that bounce off the wall. The way I would approach that would be to mirror the pool table over the wall when checking for collisions. For example, if I find that there are no direct paths from the q-ball to the target then I duplicate the board and mirror it over the wall. Then I check for direct paths to the mirrored ball checking collisions on the original and mirrored board. You will need to take into consideration the loss of velocity when the ball bounces off the wall when calculating the velocity to hit the ball it.