In this example pso.js is used to get as many balls in the pockets as possible in the first/break shot of a game of pool.
Plotting controls | Angle samples | Force samples | |||
Optimizer controls | Number of particles | Iterations |
The only parameters that a simulation takes are the angle of the shot and the force applied. The angle varies between PI/4 and PI/2 (the range has been halved since the setup of the table is symmetric). The force varies between 200 and 2000 units (in p2.js terms). In the plot, the angle varies on the X (horizontal) axis and the force varies on the Y (vertical) axis.
The plot is obtained by running the simulation in a brute-force manner. The number of balls that reach pockets is color-coded from indigo to red. Indigo indicates that no balls have reached the pockets while colors towards the red end of the spectrum indicate more balls in the pockets.