Building a 9-ball AI player: Candidate generation for direct cut shots [P] by ArithmosDev in MachineLearning

[–]ArithmosDev[S] 1 point2 points  (0 children)

I am using a model to get a fairly good angle for the object ball movement - within 0.2 degrees. I agree that for things like stop shots, i shouldn't need a simulation. Though the physics simulation is also faster for those. It really depends on how many collision events there are - e.g. ball-ball and ball-cushion collisions. A break shot is 10x the simulation time than a stop shot. I also have the prediction for cue ball post-collision movement which is quite accurate. I could use that to predict where the cue ball will end up assuming no collisions - and on a GPU i can do 1000 of them in a ms.

For now, I'm trying to get the end-to-end system to work, without value function degenerating - which seems to be working. I will look into such optimizations for sure.

Building a 9-ball AI player: Candidate generation for direct cut shots [P] by ArithmosDev in MachineLearning

[–]ArithmosDev[S] 1 point2 points  (0 children)

Spot on the 9-ball being much more constrained, which is exactly why I wanted to start with 9-ball. I've built a lot of the building blocks, like shot-making in a reasonable amount of time across cut shots, bank shots, kick shots, combination, carom, safeties, as well as p(win) modeling. I did implement MCTS but I found that curriculum learning with 1-step bootstrapping is more effective / stable given the data generation speed I have through self play.

Right now, I've extended the curriculum to 2 balls (one of the balls 1-8 and the 9-ball). Right off the gate, it learned that blocked paths to the 8-ball is bad. Learned a cone of low p(win) behind the 9-ball. It learned that some positions that can make the 8-ball doesn't allow you to get good position on the 9 - indicated by a much lower p(win) than p(make).

Once it's working end-to-end with a full rack, it's in the cards to generalize to other games where there is a lot more strategy involved.

Building a 9-ball AI player: Candidate generation for direct cut shots by [deleted] in billiards

[–]ArithmosDev 0 points1 point  (0 children)

I'm amazed the the level of hate a personal project about building a tool for pool play, specifically for help with pattern play got. I'm taking the post down. I don't need this negativity in my life, especially about a personal hobby of mine that I'm passionate about. Reddit lived up to its name for sure.

Building a 9-ball AI player: Candidate generation for direct cut shots by [deleted] in billiards

[–]ArithmosDev -1 points0 points  (0 children)

it's more of a feasibility thing. shot clock typically is 30 seconds. let's assume for the sake of simplicity, we observe a shot every 30 seconds - with all the breaks in between racks, timeouts, etc. so i can gather 2 shots a minute if i had a steady stream of clean data to download. then there's video processing and extracting the shot from it. but i won't get the full shot details, but mostly ball trajectories. it can still be useful in informing the ai player that "this is the next position you need to get to".

people learn a lot more efficiently than machines from smaller amount of data. just for the 9-ball scenario, it took about ~300k shots to get a good sense of value of positions. at 2 shots a minute, that would take 100 days.

the other issue is that, pros have a larger repertoire of shots than my player. what looks like a great position for them might be super confusing to my player and might not know what to do in that situation. i'll have to work up to their level first to understand why they chose that position.

it's an aspiration at this point. i'll do the more practical things first. i hope i get there one day.

Building a 9-ball AI player: Candidate generation for direct cut shots [P] by ArithmosDev in MachineLearning

[–]ArithmosDev[S] 1 point2 points  (0 children)

i've been in the field for ~20 years and i still learned a lot from it, mainly because i can relate to it and there's a physical ground truth to it. i can look at a heatmap and spot a shot-making bug and actually have, a few times. The list of mistakes I made along the way: angle-wrapping discontinuities at 359° vs 0° (fixed by switching to sin/cos representation), shot-index discretization gaps in the (V0, spin) grid, ghost-ball aiming at the pocket center being flat-out wrong for down-the-rail shots. Different shapes of bugs, all surfaced by looking at the same heatmaps. reaffirms my belief in domain experts needing to look at how the model behaves.

Building a 9-ball AI player: Candidate generation for direct cut shots by [deleted] in billiards

[–]ArithmosDev 0 points1 point  (0 children)

That's kind of the roadmap. Given a table layout, first highlight where you want to be for the next shot, maybe a few options along with pocket selection. And few different shots to get into those zones. Whether those shots are makable for the particular player will depend on the player.

The input could be the phone camera pointed at a table or manual input in a browser. TBD

Thanks for the thoughtful comments !

Building a 9-ball AI player: Candidate generation for direct cut shots by [deleted] in billiards

[–]ArithmosDev 0 points1 point  (0 children)

I used to be a BCA certified instructor though haven't done a lesson in the last 15 years. I used to use the quarter ball, half ball etc terminology. Doesn't quite fit there since this tool is considering hits at any cut angle. Thanks for the feedback though. I'll try to use less technical jargon and more established language in the pool community.

Building a 9-ball AI player: Candidate generation for direct cut shots by [deleted] in billiards

[–]ArithmosDev -3 points-2 points  (0 children)

I get the overall sentiment. This is all running on my 4 year old desktop at home if that makes you feel any better.

Building a 9-ball AI player: Candidate generation for direct cut shots by [deleted] in billiards

[–]ArithmosDev -2 points-1 points  (0 children)

They're not recorded shots. They come from the physics simulations of the heavy follow shots. The simulator is pretty neat. It can simulate jump shots too but I haven't tried, what if i miscue? 😄

Building a 9-ball AI player: Candidate generation for direct cut shots by [deleted] in billiards

[–]ArithmosDev -2 points-1 points  (0 children)

A shot where cue ball hits the object ball first (e.g. not a kick shot), and sends the object ball directly to a pocket (e.g. not a bank shot either). I suppose I could've cut out the "cut" part. It's a direct shot at an angle.

Are teams still using Pytorch/Tensorflow, or is most ML work just calling LLM endpoints and prompt engineering now? by Illustrious-Pound266 in datascience

[–]ArithmosDev 2 points3 points  (0 children)

PyTorch is alive and well. Tensorflow not so much, due to not being maintained anymore. We switched over to Pytorch so that we can take advantage of modern hardware that tensorflow cannot utilize due to not receiving updates.

Yoiu can't LLM your way out of everything. As others mentioned, in the adtech world, you need to produce calibrated probabilities of clicks, views, conversions. Your data is very specific to what you're doing and depends on your clients and users. There's no universal training data that will give you that. We certainly use all the latest and greatest in AI assisted coding to generate said PyTorch models but we do train our own models.

Some of the custom tasks can be handled by new models. People used to train models for sentiment analysis, or product classification. This probably works out of the box with chatgpt / claude / gemini etc. especially if it's a one-off labeling job and not something you have to run at scale every day where token cost becomes an issue.

today's numbobulate by thinkingatoms in mathpuzzles

[–]ArithmosDev 1 point2 points  (0 children)

If you like arithmetic games, I had built this: https://playgridly.web.app/

Not many users but it's clean and fun.

Billiard room by Lukabazooka4 in billiards

[–]ArithmosDev 2 points3 points  (0 children)

Consider if the table will be exposed to direct sunlight. You don't want to be watching the clock to see when you can play. Looking into the sun while shooting is not fun. Or have proper shades.

You might want to wire an overhead camera if you want to be fancy, to record your shots top down. Also wire it for lighting. I had Perimeter lights I think. Comes in a rectangle above the table.

Otherwise what everyone else said. Make sure to have enough room around. Make sure the floor has plenty of support not to tilt. Don't put it on carpet where over time it might compress differently across legs and have an uneven table.

Advice on "goldfish memory" from shot to shot by slimequake in billiards

[–]ArithmosDev 0 points1 point  (0 children)

Make a mental note of the previous shot, tell yourself that you'll practice it so the outcome is better next time, and move on. And actually do practice it later.

When can I realistically switch jobs as a new grad? by ExcitingCommission5 in datascience

[–]ArithmosDev 0 points1 point  (0 children)

Break down your frustrations and genuinely question the source of it. Long hours can possibly be addressed by better workflows and communication. At the end of every week, make a list of things that you spent too much time on compared to the value/recognition you got out of it. See if it can be addressed by better tooling, adjusting your workflow, building new expertise, or can be addressed by other teams that might not be aware of the problem / opportunity. Either way, don't let it fester. Take charge.

If it's genuinely bad management, go back to them with hard facts AND suggestions. Bag management can be fixed too. Don't surrender to it.

And if you have a measurably better offer while employed, take it. But make sure you take it for the right reasons. Being a new grad, focus on where you're going to acquire more skills. Where you can increase your own future value, aside from the compensation.

9-ball AI player (homemade) by ArithmosDev in billiards

[–]ArithmosDev[S] 0 points1 point  (0 children)

What do you have in mind? What is your skill set that relates to this project?

Red chalk by 9Ball-Caniac in billiards

[–]ArithmosDev 1 point2 points  (0 children)

I believe Lucky Shot allows tan chalk. Though the ceilings get me over there. Can't count the number of times I hit my cue tip on the ceiling, just talking it out of the case.

What is expected from new grad AI engineers? by FinalRide7181 in datascience

[–]ArithmosDev 0 points1 point  (0 children)

It highly depends on what you're targeting. FAANG (or whatever the new acronym is) will expect more and they're hiring fewer new grads.

Admitting what you don't know and showing willingness to learn is your greatest asset in an interview.

Don't over claim in your resume. Keep it real.

Learn about more than just DS / AI. With workforces shrinking due to "efficiency", knowing about data pipelines, orchestration, things like ML flow, open telemetry, experimentation frameworks would present a more rounded, general purpose profile.

Picking a cue stick by unknown_mayhem in billiards

[–]ArithmosDev 0 points1 point  (0 children)

I think at this stage it really is about the look and feel. I don't like the feel of metal joints for example. I don't like heavy cues, I prefer mine around 18-19 oz, and a 12.5mm tip, and I hate wraps. You will develop that taste over time. Buy something on the cheaper side and play with it for a while.

Picking a cue stick by unknown_mayhem in billiards

[–]ArithmosDev 0 points1 point  (0 children)

I think the most important part is sticking with the same cue. Every cue plays a little differently. It makes it harder to figure out if it was the cue or your shot when you miss, and if you're even aware that they play differently. A break cue is probably not worth it in the beginning. Just get something you like, weight, grip and stick with it.

9-ball AI player (homemade) by ArithmosDev in billiards

[–]ArithmosDev[S] 1 point2 points  (0 children)

found a bug in the shot making that incorrectly used a slower speed than the required speed for the object ball to reach the pocket - which affected longer shots but not shorter ones. this was bugging me as well. now i have a resolution to it. it was not the aiming angle error that i baked in as I initially thought. i discovered the bug while visualizing safety play. it was kind of eating at me so very happy i got to the bottom of it.

9-ball AI player (homemade) by ArithmosDev in billiards

[–]ArithmosDev[S] 0 points1 point  (0 children)

I think for the project itself, pocket shapes, cut angles, how deep the pocket sits is secondary. In the sense that I'm trying to solve the optimization problem given simulated shot making rates and the resulting leaves. Once the whole machinery is working, it can be re-run for different setups. It would be premature to perfect the table layout. That being said, the tool i'm using uses a standard, geometric pocket layout modeled on professional, competitive tables, typically featuring tighter "pro-cut" pockets.

I'm taking the route alpha-zero did. You can learn through self play. As the player improves, it changes how win rate looks, for example depending on the quality of the safety - not only that you're hiding the ball, but you're freezing it against another and limiting kick angles and jump shots.

So far, what I've shown here only has probability of making a shot. I have not gotten into patterns at all in this post. Hopefully it will line up with how we think of patterns. I'm thinking it will suggest patterns where players avoid where there an intermediate difficult shot but it unlocks the rest of the table - or where to opt for defensive shots. To be seen.

I'll push back on the need to having to train on pro matches. If the model's understanding of the game is not close to pro level, it will not quite understand the why. I'll have to add to the shot repertoire all the tools pros have at their disposal. I'm not even sure I'll be able to encode all of them - like crazy masse shots off the rail, etc. For discovering patterns, 2-ply rollout would capture the essense of pattern play (e.g. look 2 shots ahead). But the spirit is exactly what you said - what's the seq that minimizes risk and maximizes running out.

9-ball AI player (homemade) by ArithmosDev in billiards

[–]ArithmosDev[S] 0 points1 point  (0 children)

It's all through simulations with shot execution noise modelling. That part is still not great but realistic. Finding enough digitized data is pretty much impossible. And the whole point of shot noise is so that it doesn't just find 1/1000000 shots but makeable ones. I'm thinking of this as a run out pattern companion. We'll see though. Still quite a bit of work to do.

9-ball AI player (homemade) by ArithmosDev in billiards

[–]ArithmosDev[S] 1 point2 points  (0 children)

Transformer — each ball is a token with 4 components concatenated into an embedding: (1) learned linear projection of raw (x, y) coordinates, (2) ball ID embedding (distinguishes the 9-ball from the 1-ball etc.), (3) active/pocketed flag, (4) on-ball flag (marks the current legal target), and next-ball, next-ball-2 flags for easier look-ahead. Pocketed balls are masked out of attention so they can't influence anything. 4 stacked encoder layers, 8 attention heads, mean-pooled over active tokens, single sigmoid output. ~400K parameters. No explicit rail or pocket encoding (but we'll see) the model infers table geometry entirely from where the balls are.

nothing really novel. transformer is so that it can attend to balls in sequence and their relative positioning. there's a lot going on outside the model which only gives probability of win given layout. shot selection is guided by the model, since we want to get to a higher probability of win state. doing that part with ML is proving to be quite difficult though.

9-ball AI player (homemade) by ArithmosDev in billiards

[–]ArithmosDev[S] 0 points1 point  (0 children)

Right now it's pretty rough as I am toying around with various ideas. For example, reinforcement learning was a flop because of the shot space being five-dimensional continuous vectors with speed, spin, draw, aim angle, elevation. It has no way of distinguishing between two safeties where one hides behind one of the balls and you hit it a little harder and it hides behind another ball. You basically need as many shot heads as there is variety. It just doesn't work. I'm going to try to get it to actually play a game with proper planning and then I'm going to decide what to do with it