# Pool game

## Recommended Posts

Hi , I'm making a pool game and I'm at point where I can implement the AI for the game. What is the best algorithm to play pool (9-ball) ? 1. selecting the right color (full or half-full balls) 2. sorting from nearby a pocket tot far away 3. selecting only the balls who are pottable (=> no balls on the way to pocket and way from white to selected ball) 4. play the ball with right power, right angle the first and second stap aren't really difficult. I have some problems with the 3 en 4 step. My questions : 1. How do I check if a ball is pottable in a pocket ? (I guess something with angle? what is the maximum angle to pot ?) 2. What is a right angle to play a ball (how to calculate) ? Thx in advance !

##### Share on other sites
This seems like a 2-discipline question. The first part of your questions does seem to be "AI". I'd suggest posting a thread in the AI forum instead of here. Its more appropriate and on-topic there.

The second part of your question deals with geometry/math/physics. Hopefully some folks here will address that part!

##### Share on other sites
it seems that u haven't played too much pool in ur life :).
if a ball can be pottable to a specific pocket, then it must have a way to that pot. this means a rectangle with the with =diameter of ur ball and height=distance from ball to pocket. well if this rectangle does not colide with any other balls then, u have ur floor to the poket.

same goes with the other problem: is it possible to hit the ball with the cue ball? its a rectangle which must not colide.

i hape u know how balls are moving at contact. the hit ball will move perpendicular on the tangent between the 2 balls. and the cue ball will move perpendicular to the direction of the hit ball. u should see a drawing or an yahoo pool to anderstand.

maximum angle to chopt a ball is 90, but the ball will never move in reality if the angle is exactly 90(it must be less).

oh and btw. if ur not expert at math and phisics, just leave this project alone. its quite something. if u wanna make something cool ull have to analize the cueball's spinning and efects like that. its not a very beautifull thing to do ha... ever played virtual pool... imagine that. its all the fuking phizics and maths in there.

##### Share on other sites
Quote:
 Original post by Anonymous Poster...

He was asking how to calculate it, not for advice to quit the project.

I haven't gone through spheres collission in physics, but a google search yilds some interesting results.

Edit: Wait, you already implented the physics?

Then it's pretty simple.

(x1, y1) Is the position of the ball you want to hit.
(x2, y2) Is the position of the hole.

We have to find the angle that the ball has to go after it's been hit to drop in the hole.
                 x1y1+x2y2cos v = -----------------------------        sqrt(x1x1+y1y1)sqrt(x2x2+y2y2)

Now, depending on the complexity physics you've implented you have to figure out which position on the ball you want to hit to get the angle V. When you've found that, just calculate the angle between the white balls position and that position using the above and then apply that angle the white ball.

[Edited by - Coward on March 30, 2005 1:38:52 PM]

## Create an account

Register a new account

• ### Forum Statistics

• Total Topics
628383
• Total Posts
2982371

• 10
• 9
• 15
• 24
• 11