Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Calculating Pool / Billiard Shots [New]


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 rahulpawar   Members   -  Reputation: 109

Like
0Likes
Like

Posted 31 May 2012 - 07:12 AM

Hi guys,
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.

Sponsor:

#2 HappyCoder   Members   -  Reputation: 2829

Like
0Likes
Like

Posted 31 May 2012 - 10:42 PM

Just spouting off the top of my head.

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.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS