pooltool.events.datatypes#
Overview#
Classes#
- class pooltool.events.datatypes.EventType(value)[source]#
An Enum of event types
- NONE#
The null event.
- BALL_BALL#
A ball-ball collision.
- BALL_LINEAR_CUSHION#
A ball collision with a linear cushion segment.
- BALL_CIRCULAR_CUSHION#
A ball collision with a circular cushion segment.
- BALL_POCKET#
A ball pocket “collision”. This marks the point at which the ball crosses the point of no return.
- STICK_BALL#
A cue-stick ball collision.
- SPINNING_STATIONARY#
A ball transition from spinning to stationary.
- ROLLING_STATIONARY#
A ball transition from rolling to stationary.
- ROLLING_SPINNING#
A ball transition from rolling to spinning.
- SLIDING_ROLLING#
A ball transition from sliding to rolling.
Bases:
pooltool.utils.strenum.StrEnumMethods:
- class pooltool.events.datatypes.AgentType(value)[source]#
An Enum of event agents
- NULL#
A null agent.
- CUE#
A cue stick agent.
- BALL#
A ball agent.
- POCKET#
A pocket agent.
- LINEAR_CUSHION_SEGMENT#
A linear cushion segment agent.
- CIRCULAR_CUSHION_SEGMENT#
A circular cushion segment agent.
- class pooltool.events.datatypes.Agent(id: str, agent_type: AgentType, initial: NullObject | Cue | Ball | Pocket | LinearCushionSegment | CircularCushionSegment | None = None, final: NullObject | Cue | Ball | Pocket | LinearCushionSegment | CircularCushionSegment | None = None)[source]#
An event agent.
This class represents an agent involved in events. The agent can be in different states before and after an event, represented by
initialandfinalstates.- agent_type#
The type of the agent.
- initial#
The state of the agent before an event.
- final#
The state of the agent after an event.
Methods:
- set_initial(obj: Object) None[source]#
Sets the initial state of the agent (before event resolution).
This makes a copy of the passed object and sets it to
initial.In the case of a
AgentType.BALLagent type, it drops history fields before copying to save time and memory.- Parameters:
obj (Object) -- The object from which
initialwill be set.
- set_final(obj: Object) None[source]#
Sets the final state of the agent (after event resolution).
This makes a copy of the passed object and sets it to
final.In the case of a
AgentType.BALLagent type, it drops history fields before copying to save time and memory.- Parameters:
obj (Object) -- The object from which
finalwill be set.
- matches(obj: Object) bool[source]#
Determines if the given object matches the agent.
It checks if the object is of the correct class type and if the IDs match.
- Parameters:
obj (Object) -- The object to compare with the agent.
- Returns:
True if the object’s class type and ID match the agent’s type and ID, False otherwise.
- Return type:
- class pooltool.events.datatypes.Event(event_type: EventType, agents: Tuple[Agent, ...], time: float)[source]#
Represents an event.
This class models an event characterized by its type, the agents involved, and the time at which the event occurs.
Agent states before and after event resolution are stored in the
Agent.initialandAgent.finalattributes of agents withinagents.- event_type#
The type of the event, indicating the nature of the event.
- agents#
A tuple containing one or two agents involved in the event.
Events that are collisions (
EventType.is_collision()) have two agents, while events that are transitions (EventType.is_transition()), or events with event typeEventType.NONE, have one agent.By convention, the order of the agents matches how the
EventTypeattributes are named.- Type:
Tuple[pooltool.events.datatypes.Agent, …]
- property ids: Tuple[str, Ellipsis]#
Retrieves the IDs of the agents involved in the event.
This property provides access to a tuple of agent IDs, allowing identification of the agents involved in the event.
- Returns:
A tuple containing the IDs of the agents involved in the event.
- Return type:
Tuple[str, …]
Methods: