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
-
Gnome Developers Consider Dropping RPM Support
In a move that might shock a lot of users, the Gnome development team has proposed the idea of going straight up Flatpak.
-
openSUSE Tumbleweed Ditches AppArmor for SELinux
If you're an openSUSE Tumbleweed user, you can expect a major change to the distribution.
-
Plasma 6.3 Now Available
Plasma desktop v6.3 has a couple of pretty nifty tricks up its sleeve.
-
LibreOffice 25.2 Has Arrived
If you've been hoping for a release that offers more UI customizations, you're in for a treat.
-
TuxCare Has a Big AlmaLinux 9 Announcement in Store
TuxCare announced it has successfully completed a Security Technical Implementation Guide for AlmaLinux OS 9.
-
First Release Candidate for Linux Kernel 6.14 Now Available
Linus Torvalds has officially released the first release candidate for kernel 6.14 and it includes over 500,000 lines of modified code, making for a small release.
-
System76 Refreshes Meerkat Mini PC
If you're looking for a small form factor PC powered by Linux, System76 has exactly what you need in the Meerkat mini PC.
-
Gnome 48 Alpha Ready for Testing
The latest Gnome desktop alpha is now available with plenty of new features and improvements.
-
Wine 10 Includes Plenty to Excite Users
With its latest release, Wine has the usual crop of bug fixes and improvements, along with some exciting new features.
-
Linux Kernel 6.13 Offers Improvements for AMD/Apple Users
The latest Linux kernel is now available, and it includes plenty of improvements, especially for those who use AMD or Apple-based systems.