User:Prob2prob/sandbox

Description
The Offensive Play Index is meant to be an objective measurement of the quality of a player's offensive play during a match of Continuous 14.1 also known as Straight Pool. The measurement takes the form of a decimal value between 0.000 and 1.000, 1.000 being perfect play and 0.000 the worst possible play. Good amateurs will typically score between 0.600 and 0.750 and professionals between 0.750 and 1.000 but in a race to 150 or more, only top professionals can hope to score better 0.900 on a regular basis. The measure of OPI is not only meaningful after a match but also during a match provided that enough offensive play has already occurred.

The measure is objective as it relies only on objective events in the game:

1. Whether a player is:
 * playing offensively (attempting to pocket a ball by calling it or by obvious intention) -or-
 * playing defensively (with a safety shot or an intentional foul)

2. For offensive shots, what the result is:
 * One or more balls pocketed legally -or-
 * No ball pocketed (on a legal shot or on a foul)

The measure will yield a higher value when balls are pocketed in long runs. For example, in a race to 100 a player that wins the match but pockets only 4 balls and then plays safe for each of his 25 turns at the table will end up with an Offensive Play Index measure of only 0.694 compared to 1.000 for the player who runs 100 and out.

Offensive vs Defensive play
To come up with a reasonable measure for the quality of offensive play in the game of continuous 14.1, shots will be put in 2 categories:


 * Offensive play: The player attempts to pocket one or more balls while leaving the cue ball and the remaining object balls in a disposition which will allow more balls to be pocketed
 * Defensive play: The player does not attempt to pocket any balls but instead attempt to leave the cue ball and the objects ball in a disposition that will make it difficult for the opponent to pocket any balls on his turn. This might be achieve by intentionally committing a foul.

The measure Offensive Play Index is concerned only with Offensive play shots. The Defensive play shots are considered only as ending a sequence of successful Offensive play shots.

Offensive Play Index definition
Each Offensive play shot is given a value between 0.0 and 1.0 (see calculation below). The average of this value over all the Offensive play shots by a player is calculated, resulting in a value between 0.0 and 1.0. This value is squared (see explanation below) resulting in another smaller value between 0.0 and 1.0. This value is called the Offensive Play Index (OPI hereafter) for the player.

Offensive play value for a shot
Although reality is much more complex, during the continuity of Offensive play shots, we will say that, to pocket a ball on shot #s, a player has to acquire position on shot #s-1 and acquire position for the position (p4p hereafter) on shot #s-2. Failure to acquire position on shot #s-1 and p4p on shot #s-2 results on the ball for shot #s to be missed or the player switching to a Defensive play shot.

In more details, a total of 6 tasks must be accomplished successfully in order for a ball to be pocketed on shot #s

Since all of these 6 tasks are mandatory for shot #s to be successful, we will grant 1/6 of point for each. If all are successful, a ball is pocketed on shot #s.

Conversely, the tasks that a player is trying to complete on shot #s, not only with respect to ball b but with respect to other balls as well are as follow:

That is a total of 6 tasks worth each 1/6 of a point for a maximum of 1 point to be attributed per shot. This total will constitute the value from 0.0 to 1.0 that will be given to an Offensive play shot.

Since the concepts of obtaining position and obtaining position for the position are subjective in nature while OPI is meant to be measured objectively, the test as to whether task #4, #5 and #6 have been completed will be as follow:

To summarize, during continuous Offensive play, for a shot #s, a player will be give 3/6 of a point if a ball is pocketed on shot #s, 2/6 of a point if a ball is pocketed on shot #s+1 and 1/6 of a point if a ball is pocketed on shot #s+2 for a maximum of 1 point for shot #s.

Effect of missing
When a player misses (pockets no ball legally on an Offensive play shot), all 6 tasks are considered incomplete. Task #1, #2 and #3 are incomplete because ball b was not pocketed, task #4 and #5 are incomplete because shot #s+1 will not even be played and task #6 because shot #s+2 will not be played either. So a player gets 0 for a missed shot.

Effect of going to a Defensive play shot
As mentioned before, the OPI measure is only concerned with Offensive play so when a player plays a Defensive play shot after a sequence of 1 or more successful Offensive play shots, the player obviously gets no point for the Defensive play shot. However, the shot is not considered in the calculation of OPI, it does not add 1 to the denominator in the calculation of the average of OPI values. Consequently, the negative effect of playing a Defensive play shot is much less than missing on an Offensive play shot.

Starting an Offensive play run
According to this model, a player needs position to pocket a ball. The player also needs p4p in order to acquire position on a second ball and pocket it. So when a player is able to start an Offensive play run of 1 ball or more, who is considered to have provided the position (and the position for the position if the player pockets 2 balls or more)?

It is consider that the position and the p4p was provided -accidentally- by his opponent, the player receives no point for this. If the player does not have position when the opponent loses his turn it is assumed that the player will not attempt an Offensive play shot and so, it has no impact on the calculation of OPI. It could be argued that when a player pockets a ball on the first shot of a run and misses (or switches to Defensive play) on the second shot, it might be because the opponent provided position but not the p4p on his last turn-losing shot and thus, it can be argued that the player should not be penalized for missing his second shot. For simplicity, it is assumed that the opponent always accidentally provides position -and- p4p when he loses his turn -or- neither of them.

Shots not played yet
In the course of a match, to calculate OPI, shots that have not been played yet will all be calculated as successful until they are played. This will elegantly keep the value of OPI at 1.0 until the player misses or switches to Defensive play for the first time.

Shots that will never be played
In order to make the value of 1.0 for OPI possible, at the end of a match, the points granted for getting position -and- p4p for shots that will not be played (because the match ended) will nevertheless be granted.

So let's say a match ends with a player pocketing a ball on shot #241 and another ball on shot #242 and so winning 150 to 92. The player will be granted 1.0 point (instead of 5/6 of a point) for shot #241 even tough shot #243 was not played and there is no way to judge if the player got position for the position on shot #241.

The player will also be granted 1 point (instead of 3/6 of a point) for shot #242 even tough shot #243 and shot #244 were not played and there is no way to judge if the player got position -and- position for the position on shot #242.

Pocketing more than 1 ball
Sometimes more than 1 ball are pocketed on an Offensive play shot. In reality this is almost always accidental so, for the purpose of calculating OPI, pocketing more than 1 ball gives no additional points.

Squaring the average
As mentioned before, the Offensive Play Index is calculated by squaring the average of the Offensive play shot values. This is done because even an absolute beginner who always pockets only 1 ball and then misses would still be attributed an OPI of 0.250 if the value was not squared, making the entire range of values 0.000 to 0.250 almost never used and the range from 0.250 to 0.500 rarely used. Squaring a value between 0.0 and 1.0 results in a smaller number still between 0.0 and 1.0. That gives more definition at the top of the OPI range where most players perform.

Flaws
The model assumes that any time a player attempts an Offensive play shot, his intentions are to continue pocketing balls and run out. In really it is not uncommon for a player to pocket 1 or 2 balls fully intending to play safe on the next shot. Here the model assumes that the player lost position and he is granted only partial points for the 2 successful shots. This can have a big impact on the OPI measure if it happens more than once or twice in a match. A better model could give full points for short runs of 1 or 2 if they are followed by a safety shot.
 * Assumption of continuous offensive play intention

The model assumes the any time a player attempts and Offensive play shot after an opponent's turn at the table ends, he has not only position to pocket a ball but also the position for the position to pocket the ball after. In reality, a player might be forced to attempt a very difficult shot with no obvious next shot as it is his best option. This could be because the opponent played an extremely good safety with no safety answer -or- the opponent "missed well" leaving no easy shot and no safety to the player by pure luck. As OPI is not meant to measure the safety play or the level of luck of the opponent this can be considered a flaw in the model. A better model could give less importance to shots that are after opponent turn-losing shots.
 * Assumption of player having good position after opponent misses

Perfect match
In a race to 100 between Alice and Bob, the match goes as follow:

Alice

Alice attempted 100 Offensive play shots, shots #002 to #101

For shots #002 to #099, Alice obtains 3/6 of a point for pocketing the ball, 2/6 for pocketing the ball after and 1/6 for pocketing the 2nd ball after. That's 98 times 1 point so 98 points.

For shot #100, Alice obtains 3/6 of a point for pocketing the ball, 2/6 for pocketing the ball after on shot #101. As explained above, she is also given 1/6 or a point for free because there is no shot #102, the match having ended. This is another 1 point.

For shot #101, Alice obtains 3/6 of a point for pocketing the ball. As explained above, she is also given 2/6 of a point and another 1/6 or a point for free event because there are no shot #101 and #102, the match having ended. This is another 1 point.


 * OPI for Alice = (100 points / 100 shots) ^ 2 = 1.000

Bob

Bob attempted no Offensive play shots. His only shot was the break shot where he called safe, a Defensive play shot which is not considered for the calculation of OPI. This is a rare case where OPI remains undefined for an entire match. This result can be represented as N/A or any other symbol or expression that signifies 'no value can be calculated'.


 * OPI for Bob = N/A

Almost perfect match (1 safety)
In a race to 200 between Alice and Bob, the match goes as follow:

Alice

Alice attempted 200 Offensive play shots, shots #002 to #101 and #104 to #203

For shots #002 to #099, Alice obtains 3/6 of a point for pocketing the ball, 2/6 for pocketing the ball after and 1/6 for pocketing the 2nd ball after. That's 98 times 1 point so 98 points.

For shot #100, Alice obtains 3/6 of a point for pocketing the ball, 2/6 for pocketing the ball after on shot #101. This is 5/6 point. For shot #101, Alice obtains 3/6 of a point for pocketing the ball. This is 3/6 point.

For shots #104 to #201, Alice obtains 3/6 of a point for pocketing the ball, 2/6 for pocketing the ball after and 1/6 for pocketing the 2nd ball after. That's 98 times 1 point so 98 points. For shot #202, Alice obtains 3/6 of a point for pocketing the ball, 2/6 for pocketing the ball after on shot #101. As explained above, she is also given 1/6 of a point for free because there is no shot #204, the match having ended. This is another 1 point. For shot #203, Alice obtains 3/6 of a point for pocketing the ball. As explained above, she is also given 2/6 of a point and another 1/6 or a point for free event because there are no shots #204 and #205, the match having ended. This is another 1 point.


 * OPI for Alice = (98 + 5/6 + 3/6 + 98 + 1 + 1) / 200 ^ 2 = (199 / 200) ^ 2 = 0.99334444

Bob

Bob attempted 1 Offensive play shot, shot #103.

For shot #103, Bob gets no points.


 * OPI for Bob = (0 / 1) ^ 2 = 0.00000000

Almost perfect match (1 miss)
Same match as above except that on shot #102, Alice misses instead of playing safe. Shot #102 is now an Offensive play shot so point must be attributed to it.

Alice

Alice attempted 201 Offensive play shots, shots #002 to #102 and #104 to #203

All the points attributions are the same except for the following addition:

For shot #102, Alice gets no points.


 * OPI for Alice = (98 + 5/6 + 3/6 + 0 + 98 + 1 + 1 / 201 ) ^ 2 = (199 / 201) ^ 2 = 0.98348500

Bob

Bob attempted 1 Offensive play shot, shot #103.

For shot #103, Bob gets no points.
 * OPI for Bob = (0 / 1) ^ 2 = 0.000

50 shots of a real life match
In a race to 200 between Alice and Bob, the first 50 shots of the match are as follow:

OP value for shot

The column OP value for shot shows the Offensive play value taking into account the shots played after. For example on shot #4 and #5 the values given are 5/6 and 3/6 because it is taken into account that shot #6 is a miss. During play, just before shot #6 it is not known that shot #6 will be a miss shot and the values for shot #4 and #5 would be 1.0 and 1.0.

OPI (real time)

The column OPI (real time) shows the OPI value that would be shown during play, not knowing what is the results of the shots after the current one. For example, after shot #5 the OPI for Bob is still 1.000 although he will miss the next shot. This is because, as explained above, shots that have not been played yet are assumed to be successful Offensive Play shots.

Data collection
A software that calculate OPI must not only record the results of each shot ( Ball made / Legal shot-No ball made / Foul ) but also what was the intention of the player on the shot ( Make ball / Safe / Take foul). Although the "Ball made" result implies a "Make ball" intent, a "Legal shot-No ball made" result can have had a "Make ball" intent, a "Safe" intent and even in some rare case a "Take foul" intent. A "Foul" result can have had all 3 possible intents as well. But not all distinctions are necessary to calculate OPI. The results "Legal shot-No ball made" and "Foul" need not be differentiated (both are failed Offensive play shots). The intent "Safe" and "Take Foul" (both Defensive play shots) do not need to be differentiated either.

Software tools calculating OPI

 * Fourteen-One Engine

The Fourteen-One engine software feature a number of scoreboards and stat boards aimed at being added to a streamed match of 14.1 or added at post-production to the video of a match. OPI is one of the stats shown on the stats boards.