A unique identifier generator that uses physically simulated billiards breaks to create cryptographically unique IDs.
BUID (Billiards Unique Identifier) generates unique identifiers by simulating a billiards break shot using real physics. Each ID generation creates a virtual pool table with 28 balls arranged in a triangle formation, then strikes them with a cue ball at randomized velocity. The final positions of the balls after the physics simulation completes are used to generate a unique alphanumeric identifier.
- Physics-Based Randomness: Uses the Chipmunk2D physics engine for realistic ball interactions
- Low Collision Rate: Only 0.08% chance of generating duplicate IDs
- Deterministic from Input: Same velocity input produces same ID (useful for testing)
- Alphanumeric Output: Generated IDs contain digits (0-9), uppercase (A-Z), and lowercase (a-z) characters
- High Performance: Capable of generating thousands of IDs per second
- Setup: Creates a 60x60 unit virtual pool table with walls
- Ball Arrangement: Places 28 balls in a triangular rack formation
- Break Shot: A cue ball strikes the rack with randomized velocity (45-95 X, ±4 Y)
- Physics Simulation: Runs for 10 seconds of simulated time (600 physics steps)
- ID Generation: Maps final ball positions to alphanumeric characters
The physics simulation includes:
- Realistic ball elasticity (0.95)
- Friction between balls and table (0.03)
- Energy dampening (0.5) to settle the balls
- Collision detection and response
go get github.com/DillonEnge/buidpackage main
import (
"fmt"
"log"
"github.com/DillonEnge/buid"
)
func main() {
id, err := buid.New()
if err != nil {
log.Fatal(err)
}
fmt.Println("Generated BUID:", id)
}Generated BUID: Qmd9RveLdVYbYDfSfdVlfJgNiSleZlmDiLkQkZmbikqCqFlOqSlVtZcr
The criteria, features and results of a locally run benchmark (M3 Macbook Pro) were as follows:
- Throughput: 10,000 IDs generated in parallel
- Collision Testing: Duplicate IDs tracked across generations
- Timing: Total operation time recorded
Benchmark output:
op time: 9.341s
id conflicts: 0.08%
- Chipmunk2D Go - Physics simulation engine
- Go 1.24.2 or later
- Table Size: 60x60 units
- Ball Diameter: 2 units
- Ball Count: 28 balls + 1 cue ball
- Simulation Time: 10 seconds (600 steps at 60 FPS)
- Ball Elasticity: 0.95
- Table Friction: 0.03
- Damping: 0.5
Traditional UUID generators typically rely on timestamps, random numbers, or MAC addresses. BUID takes a novel approach by leveraging chaotic physical systems. Even tiny changes in initial conditions (cue ball velocity) result in dramatically different final ball arrangements, providing natural entropy and uniqueness.
The billiards simulation creates a deterministic but chaotic system where:
- Small input changes create large output differences
- The physics engine ensures realistic ball interactions
- Multiple collision events amplify initial randomness
- Final positions provide high-entropy state for ID generation
"A new style of ID generation, with a humourous twist"