Valid XHTML 1.1

Pool Simulation
University: Games AI and Simulation, Final Year (2010).


Pool Simulation
Prolog Programming
Graphical Techniques
Top Trumps
Guessing Game & Monte Carlo Pi
10 Second Video


Pool Simulation was a project developed during the final year at University for the Games AI and Simulation module. The underlying code for the simulation was provided already and it was our task (as students) to add the physics and collision detection. This was a fun project to code and provided insight into using vectors for physics simulation. It was very rewarding to witness the balls collide together accurately for the first time. Like the Graphics Programming Demo, this project was developed in Visual Studio with OpenGL.

The first stage in adding physics was to get the cue ball to move and collide off the cushions correctly. Once that was achieved I had to model the rotational characteristics of the ball (rolling and friction). The final and most demanding stage was to add more balls and get accurate collision detection and reaction working between all balls on the table.


Wireframe view of the table, racked and ready to go.

The collision detection highlighted an issue that involving high-energy collisions. When a ball impacted the cushions at a high enough velocity it could pass beyond the barrier and carry on – escaping the table entirely. In order to avoid this behaviour I added in a check before updating a balls position to see if it would collide with a cushion or ball in the next frame. While this prevented balls from escaping it did cause balls to bounce off thin air instead. The issue was finally laid to rest when I discovered a flaw in my understanding of vectors which had led to me over-complicating my collision algorithm.


The table after a snooker-style break.


You can download the executable in Rar (7 KB) or Zip (8 KB) format.
Pool Simulation: RAR ZIP


Return to Top