Billiard AI, how?

Started by
28 comments, last by ogracian 20 years, 8 months ago
Hello I am coding a billiard game and actually all works fine but it is only 1P right now, so I am trying to figure out how can I add some AI player but unfortunatly have no clue about how implement a Billiard AI. So I really appreciate if someone could point me to some methods or docs to learn about it? Thanks in advance, Oscar
Advertisement
one way you could do it would be to calculate the perfect shot for any given ball configuration, then add some error depending on difficulty level. Or make the computer aware of more advanced shots and combinations depending on difficulty.
You could just pick a number of random angles and powers, simulate them and then take the one which yeilds the best result. Kinda brute-force, but it should get you started quite fast.
delete this;
Hi

Thanks for your replay, well about computing the best shoot, it sounds cool but seems hard to find a best shoot for any ball config. Could you expand this method a litte?

And about "brute force method" seems really easy to implement, I will check it to get something working!

Regards,
Oscar
I take it you'd need to read/learn/ask some pro about playing billiard and finding out the small tricks and hints about what goes in there and the pros' ways of doing perfect shots, to then implement them into the game.

[edited by - M3d10n on August 10, 2003 7:35:52 PM]
Well, it depends on the rules you''re playing under, but in general:
play just like in real life
cast rays from cue to all the balls of interest, testing for intersections
find a reasonable number of shots you can do
if there are none look for a spot on the table that would be difficult for the other side to shoot from
make a tree thing, uh, graph, I forgot what it''s called, basically the same thing like in tic-tac-toe or chess or the ai for almost any board game really where you look, and look for the best sequence of possible moves, maybe a more advanced version would look at sequences of moves that if they get screwed up would place the other player in a good position
pick one
then shoot

now then, as far as the ai shooting, for realism
I''d use a different pre-trained neural net for each skill level but then again I have no idea what kind of inputs that would take, for starters you might use whatever input the player uses to shoot
so you could just use a random error with different settings for different skill levels
Hi

Thank you so much for your help, and for your replay, I have a lot to learn and a lot to do.

well I guess I will start it simple kind of brute force plus ray tests, and I hope to evole in a more advanced method like neural nets, for now I just want to get some simple CPU Oponent : )

Best Regards,
Oscar
"... make a tree thing, uh, graph, I forgot what it''s called, basically the same thing like in tic-tac-toe or chess or the ai for ..."
alpha beta prunning tree,if I can remember.
My english is very poor.Please correct me if There are any mistakes in my post
AI for a billiard game seems like a particularly tough problem -- an infinite choice of shots, the outcome of a shot is probabilistic and non-linear, and computing the outcome of a shot can be very expensive.

I suggest you repost this question in the AI forum. There are people in that forum that can give you much better answers than you've seen here.

BTW, neural nets are not likely to be useful.

Here is how I would tackle it.

1. Use a game tree.
2. Develop a set of rules to restrict the number of possible shots to a reasonable number.
3. Figure out ways to reduce the cost of determining the outcomes of a shot for AI purposes.
4. Figure out a way to evaluate the state of the game with as few simulations as possible.

[edited by - JohnBolton on August 11, 2003 12:48:22 PM]
John BoltonLocomotive Games (THQ)Current Project: Destroy All Humans (Wii). IN STORES NOW!
I think some of the people here might be over complicating things. I play pool a lot, and if you ask me, theres 2 things that makes a shot easy (or hard, depending on how you look at it):

1: The angle between the object ball-cue ball line and the object ball-pocket line. the bigger the angle (up to 180 degrees - ie a straight shot), the easier the shot.

2: The distance between the cue ball and object ball + the distance betweent the object ball and the hole. the longer the shot, the harder.


You can experiment around and find a good combination of these two. Whats worse: a really long straightshot, or a really short shot at an acute angle? anyway you get the idea. For an opponent, you can make the more skilled opponent better at spotting the easy shots, and his accuracy better. For a crappy opponent, you could for example randomly pick one of the 3 easiest shots, since beginner pool players dont always attempt the easiest shot for lack of spotting them.

This is a rather simplistic way to do it, but its the way i would go, at least for starters.

One thing it doesnt take into account is something expert players do - a big factor of what is the best shot is where they think they can make the cue ball stop after the shot is over to set themselves up for a good next shot. Its easy to picture a situation where the obvious easiest shot is not the best move because making that should would leave the cue ball in a very bad spot for your next shot.

Easy to picture, but not so easy to code.

This topic is closed to new replies.

Advertisement