A quick and unrealistic simulation of a billiard table
The scenario that should be simulated can be configured in a YAML file. You can specify this file as python -m billiards_sim config.yaml
. An example can be found in example_config.yaml
.
The following options exist:
Optional, default: 60
This configures the frames rendered each second. A higher value makes the animation look smoother and increases the simulation accuracy.
Optional, default: 10
This option sets the number of simulation steps that are calculated for each animation frame. An increase in this value can be used to compensate for a decrease in fps
.
Optional, default: 1270
Table width in mm.
Optional, default: 2540
Table length in mm.
Optional, default: 28.6
Ball radius in mm.
Optional, default: true
When true, inverts the y axis so that (0|0) is in the bottom left corner.
Optional, default: false
When true, the simulation starts paused. Press space to unpause.
Optional, default: 0
The friction of the balls on the table in mm/s².
Optional, default: empty
This option contains a list of pockets that should be added to the table. The following options can be used to define a pocket:
Required
Defines on which side (top
, left
, bottom
, right
) or corner (top_left
, top_right
, bottom_left
, bottom_right
) of the table the pocket should be positioned.
Required if side
doesn't specify a corner, otherwise not allowed
Used to position the pocket. Specifies the distance in mm from the 0 coordinate on this side.
Required
The distance between the two ends of the pocket.
Optional, default: empty
This option contains a list of balls the simulation starts with. The following options can be used to define a ball:
Optional, default: none
A ball's name can be used to define actions involving this ball.
Required
An array that specifies the RGB color value of the ball.
Optional, default: false
When true
, the specified color is used as the color of a stripe on white background.
Required
Specifies the initial coordinates of the ball.
Required
Specifies the initial velocity of the ball.
Optional, default: empty
This option contains a sequence of actions that should be executed in the simulation. An action ends when all balls have stopped moving. Each action is defined by the name of the ball to apply it to and exactly one action type. The following options are possible:
Required
The name of the ball that should be used when performing the action.
Action type, only one per action
This action sets the ball's velocity to the given value.
Action type, only one per action
Use this action to push a ball to a destination by hitting it with another ball. The following options are available:
Required
The name of the ball that should be hit and pushed to the destination.
Required
The destination the pushed ball should move towards.
Required
The absolute velocity the pushing ball should be hit with.
Optional, default: none
The pushing ball can be moved so that it bounces off a rail before hitting the target ball. This option is used to specify which rail is to be used (top
, left
, bottom
, right
). When set to auto
, the simulator decides whether a rail should be used and which rail is optimal, ignoring any balls in the way.