pooltool.ruleset.utils#

Overview#

Classes#

StateProbe

Enum where members are also (and must be) strings

Function#

get_pocketed_ball_ids_during_shot(shot, exclude)

Get list of ball IDs pocketed during the shot

get_pocketed_ball_ids(shot)

Get list of ball IDs that are in the pocketed state (by end of shot)

respot(shot, ball_id, x, y, z)

Respot a ball

get_lowest_ball(shot, when)

Get the lowest ball on the table at start or end of shot

get_highest_ball(shot, at_start)

Get the highest ball on the table at start or end of shot

Classes#

class pooltool.ruleset.utils.StateProbe(value)[source]#

An enumeration.

Bases: pooltool.utils.strenum.StrEnum

Functions#

pooltool.ruleset.utils.get_pocketed_ball_ids_during_shot(shot: pooltool.system.datatypes.System, exclude: Set[str] | None = None) List[str][source]#

Get list of ball IDs pocketed during the shot

See also get_pocketed_ball_ids

Return type:

List[str]

pooltool.ruleset.utils.get_pocketed_ball_ids(shot: pooltool.system.datatypes.System) List[str][source]#

Get list of ball IDs that are in the pocketed state (by end of shot)

See also get_pocketed_ball_ids_during_shot

Return type:

List[str]

pooltool.ruleset.utils.respot(shot: pooltool.system.datatypes.System, ball_id: str, x: float, y: float, z: float | None = None) None[source]#

Respot a ball

Parameters:

z (Optional[float]) -- If not provided, z is set to the ball’s radius

Notes

  • FIXME check if respot position overlaps with ball

pooltool.ruleset.utils.get_lowest_ball(shot: pooltool.system.datatypes.System, when: StateProbe) pooltool.objects.ball.datatypes.Ball[source]#

Get the lowest ball on the table at start or end of shot

Parameters:

at_start -- If True, the lowest ball on the table at t=0 is calculated. If False, the lowest ball at the end of the shot (t=inf) is calculated. The latter returns a different result if the lowest ball on the table was pocketed

Return type:

pooltool.objects.ball.datatypes.Ball

pooltool.ruleset.utils.get_highest_ball(shot: pooltool.system.datatypes.System, at_start: bool) pooltool.objects.ball.datatypes.Ball[source]#

Get the highest ball on the table at start or end of shot

Parameters:

at_start (bool) -- If True, the highest ball on the table at t=0 is calculated. If False, the highest ball at the end of the shot (t=inf) is calculated. The latter returns a different result if the highest ball on the table was pocketed

Return type:

pooltool.objects.ball.datatypes.Ball