Closed zhaodong-wang closed 6 months ago
Actually after checking into the code, I have a follow up question: why would we choose to use some fixed physics formula as evolution or resolution instead of directly leveraging some physics engine like Bullet? Maybe that can generate more realistic results? I see that pandas3d has bullet support.
Hi @zhaodong-wang, currently all ball trajectories are bound to the table. There are no other hurdles besides time that prevent extension to the third dimension.
The design philosophy of pooltool prioritizes modular, custom physics. While realism is currently subpar due to the current physics models being used, the framework allows for future improvements and the integration of advanced physics models that are far more realistic than the out-of-box solutions afforded by a real-time physics engine such as Bullet. For example, it is on the roadmap to include the Mathavan et al treatment for the ball-cushion interaction (see here).
Furthermore, the Bullet engine use discrete time evolution algorithms to advance the system state. Pooltool is fundamentally different in that it uses an event-based evolution algorithm. To learn more about their differences, see this blog post.
That said, some very preliminary experimentation with Bullet has been performed, but not with much success (link here). If you think this is a direction worth moving in, I would encourage you to experiment and see if you can get something working. Please report back.
@ekiefl thank you for the comprehensive explanation! I now grasp your motivation more clearly. Interestingly, a few years back, I embarked on a similar endeavor. My aim was to employ RL to train an AI agent to play pool at a professional level. I believe this challenge is even more daunting than mastering Go, given the vast action space and the inherent unpredictability in cue actions. Crafting a model that can decide the optimal sequence of shots and positions akin to a professional player is quite an uphill task. Although there are several papers addressing this issue, I feel they somewhat underestimate its complexity, particularly since they lack the nuanced understanding of pool play at a near-professional level.
Initially, I utilized pybullet, the go-to library for RL at the time, to create a fairly robust environment. The quality was not bad, e.g., break shot, jump shot. The missing piece that I didn't get into implementation was the soft-body modeling of the cushion (such that I can repro some cushion compression effects, example). My objective was to develop something akin to ShootersPool, which I still regard as the premier pool simulator. However, the simulation speed in pybullet was insufficient for effective RL model training due to its low sample efficiency. Subsequently, I came across a repo fastfiz that employs discrete event simulation, trading off a bit of accuracy for speed, yet still maintaining sufficient fidelity. By integrating the physics models mentioned in your papers and rectifying some bugs, I achieved the simulation speed I desired. I didn't get a decent RL policy at the end, but this was a fun journey and I learned a lot..
I concur with your endorsement of discrete event-based simulation (DES), having utilized it in other projects myself (like this) (btw, The SimPy library offers a great abstraction of DES using coroutine-style syntax, making it less prone to errors, albeit slightly slower, but there is also a simcpp20). I'm curious to know if you're still actively developing this library. I genuinely believe that a high-quality, open-source pool simulator on par with ShootersPool could significantly demystify numerous aspects of billiards, which typically require high-speed cameras or extensive experiments for elucidation.
@zhaodong-wang, the RL-based AI agent sounds like a really interesting project, and it's similar to a project I am working on in collaboration with the folks at LightZero.
The quality was not bad, e.g., break shot, jump shot
This looks awesome. Thanks for sharing. I agree that speed is a major drawback for using pybullet.
I'm curious to know if you're still actively developing this library
Yes, I am. And I anticipate I will be for a long time.
btw, The SimPy library offers a great abstraction of DES using coroutine-style syntax, making it less prone to errors, albeit slightly slower, but there is also a simcpp20
Good to know. I would be curious if the simulation speed could be increased by using these out-of-box tools. The pooltool shot evolution algorithm is already quite fast as it is compiled into machine code using numba, but it would be nice to benchmark. One drawback to the current code is the lack of parallelization. Advancing to the next event requires calculating the time until all possible events, which for a game like 8-ball--with 15 balls and 40 cushion segments--can be close to a thousand root solving operations per time step.
If you're interested in getting involved, please let me know.
This conversation is now off-topic. Please join the discord if you want to discuss ideas further (https://discord.gg/8Y8qUgzZhz)
Hi, this is a very nice open source tool. I'm wondering since it's 3D model, does it support jump shot or masse shot? Or any tiny jumps of the cue ball when the cue is not leveled?