Pool simulation with Go and Fyne
Programming Snapshot – Go Pool Simulation
To improve his skill at the pool table, Mike Schilli sets out to program a simulation in Go using the Fyne framework.
If you just aim by the seat of your pants at the pool table in the pub, the results will vary between brilliant and downright embarrassing. That's why I decided to finally learn the angle at which you have to hit a ball so that it heads off in the right direction, straight for the pocket. To do this, I studied Poolology [1], which explains the strategy in detail. I don't have a pool table at home to practice on, so I wondered: How difficult would it be to write a graphical simulation of the pool balls in Go? That way I could try out the technology onscreen before challenging the biggest pool hustlers in the wickedest pool halls of San Francisco.
In the simplest of cases, pool players shoot the cue ball straight into the ball to be played, and the cue ball hits the colored ball right in the middle (you hope). The colored ball absorbs the energy of the cue ball and moves in the same direction, while the cue ball remains stationary – unless you used a trick such as spin. Things become more complicated if you hit a colored ball at an angle. In that case, it will shoot off to the side while the cue ball keeps moving along a deflected path. The angles here depend on the amount of overlap with which the colored ball was hit. In more concrete terms: If a pool player does not aim at the center of a ball but exactly at its edge (called a half-ball), the colored ball drifts away at an angle of about 30 degrees.
[...]
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
Endless OS 6 has Arrived
After more than a year since the last update, the latest release of Endless OS is now available for general usage.
-
Fedora Asahi 40 Remix Available for Macs with Apple Silicon
If you've been anticipating KDE's Plasma 6 for your Apple Silicon-powered Mac, then you're in luck.
-
Red Hat Adds New Deployment Option for Enterprise Linux Platforms
Red Hat has re-imagined enterprise Linux for an AI future with Image Mode.
-
OSJH and LPI Release 2024 Open Source Pros Job Survey Results
See what open source professionals look for in a new role.
-
Proton 9.0-1 Released to Improve Gaming with Steam
The latest release of Proton 9 adds several improvements and fixes an issue that has been problematic for Linux users.
-
So Long Neofetch and Thanks for the Info
Today is a day that every Linux user who enjoys bragging about their system(s) will mourn, as Neofetch has come to an end.
-
Ubuntu 24.04 Comes with a “Flaw"
If you're thinking you might want to upgrade from your current Ubuntu release to the latest, there's something you might want to consider before doing so.
-
Canonical Releases Ubuntu 24.04
After a brief pause because of the XZ vulnerability, Ubuntu 24.04 is now available for install.
-
Linux Servers Targeted by Akira Ransomware
A group of bad actors who have already extorted $42 million have their sights set on the Linux platform.
-
TUXEDO Computers Unveils Linux Laptop Featuring AMD Ryzen CPU
This latest release is the first laptop to include the new CPU from Ryzen and Linux preinstalled.