O'Reilly logo

Baseball Hacks by Joseph Adler

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Keep Score, Project Scoresheet–Style

Use the Project Scoresheet system to record the plays during a baseball game.

About 20 years ago, a group of baseball fans started Project Scoresheet. This was a collaborative effort by baseball fans to record every play of every game. Bill James started this project out of frustration because the Elias Sports Bureau (the official statistics provider) refused to make this data available to fans. So, in true hacker tradition, the members of the project designed a neat, simple scoring method that was perfect for describing plays to computers. Today this system lives on as the preferred encoding method of Retrosheet. In fact, it’s even used by STATS, Inc. and the Elias Sports Bureau.

With Project Scoresheet record keeping, you write down a code each time something happens during the game, in chronological order. You don’t need two score sheets (one for each team) or special scoring paper. Even better, you don’t need to use any weird symbols—you can just write codes using the letters of the alphabet. This makes Project Scoresheet descriptions ideal for computer use because they’re easy to enter, email, and save to a database. The disadvantage of this system is that it’s a little tough to compute a box score by hand or manually read a game description. After you get the hang of this system (and you learn all the codes, which admittedly is a big hurdle), you may find it faster and easier than traditional scoring.

Even if you never plan to use this system, you might find it helpful to read this hack because Retrosheet uses this system to describe play-by-play data. We’ll revisit Project Scoresheet–style scoring throughout the book. For example, once you’re familiar with the system, you can use it to understand historical play-by-play information [Hack #14] .

The Contents of a Play Code

Each play code in this system captures several types of information:

Fielding of balls in play

When a ball is put in play, the pitching team will field the ball. Number codes are used to describe who fields the ball and to whom they throw the ball.

Type of play

Each at bat results in a walk, hit by pitch, single, double, triple, home run, or out. Codes are also used to describe any outs made during the play: normal outs, fielder’s choice, sacrifices, double plays, triple plays, force-outs, strikeouts, pickoffs, and caught stealing.

Description

Codes are used to describe the type of hit: line drive, ground ball, fly ball, bunt, and lots of other things.

Base running

When a ball is put in play, base runners can advance, and they can be put out. Within an at bat, base runners can attempt to steal bases. Runs scored are a special case. (They are an advancement to home plate.)

Errors

The pitching team can make a number of mistakes captured in this code: passed balls, wild pitches, balks, interference calls, throwing errors, foul ball errors, and other errors. The batting team can make base running errors.

Substitutions

Play codes capture pinch runners.

Play code structure.

Each play code follows a simple sequence:

	[<type>] <fielding> [ / location] [/ <description>] [ .<base runner advancement> ]

The first code represents the “type of play.” This code is optional. The second code represents any players who fielded the ball. The third code represents how the ball moved (i.e., ground ball, fly ball, etc.). A period (.) precedes the base running description. The final code describes any base runners that advanced on the play; a semicolon separates descriptions.

Fielding.

The fielding codes describe who fielded that ball and where he threw it. The letter E preceding a number indicates that the player made an error. On a play where more than one out is made, parenthetical notes describe which fielder put out which base runner. Let’s give a few examples of fielding:

13

Throw from pitcher to first baseman.

643

Throw from shortstop to second baseman to first baseman.

24

Throw from catcher to second baseman.

E3

Error by first baseman.

6E5

Throw from shortstop to third baseman. Error as ball is dropped by third baseman.

64(1)3

Fielded by shortstop, thrown to second baseman. Second baseman puts out runner from first and then throws ball to first baseman, who puts out batter.

Type of play.

Let’s start with things that happen before or during an at bat, leaving the batter still batting:

Table 1-2. 

Code

Meaning

PB

Passed ball

WP

Wild pitch

BK

Balk

SB

Stolen base

PH

Pinch hitter

PR

Pinch runner

FLE

Foul ball error

That’s not too complicated, is it? Now, let’s list the codes for hits:

Table 1-3. 

Code

Meaning

S

Single

D

Double

T

Triple

HR

Home run

DGR

Ground rule double

Now, let’s show the codes for at bats where there is no hit, but the runner reaches base:

Table 1-4. 

Code

Meaning

W

Walk

IW

Intentional walk

HP

Hit by pitch

C

Catcher’s interference (usually C/E2; I explain the “/E2” part shortly)

K+

Strikeout, but batter advances to first base on a wild pitch (this is kind of a weird, complicated one and is usually scored as “K+WP”; I provide more about the “WP” part shortly)

There are a few codes for outs during at bats. These are accompanied by codes in parentheses that describe how the ball was fielded. For example, CS2(26) means that a batter was caught stealing second on a throw from the catcher to the shortstop.

Table 1-5. 

Code

Meaning

PO1(<fielding note>)

Pickoff at first base

PO2(<fielding note>)

Pickoff at second base

PO3(<fielding note>)

Pickoff at third base

CS2(<fielding note>)

Caught stealing second base

CS3(<fielding note>)

Caught stealing third base

CSH(<fielding note>)

Caught stealing home base

Finally, here are the codes for outs at the end of an at bat:

Table 1-6. 

Code

Meaning

K

Strikeout

No code, just a number

An out (the numbers represent the player who fielded the ball; I explain these codes in the next section)

Description.

The ball movement codes describe how the ball was hit, or they elaborate on the type of out. Note that a slash (/) character precedes each code.

Table 1-7. 

Code

Meaning

/G

Ground ball

/L

Line drive

/FL

Foul

/B

Bunt

/FC

Fielder’s choice

/FO

Force out

/GDP

Ground into double play

/DP

Other double play

/TP

Triple play

/SH

Sacrifice hit

/SF

Sacrifice fly

/P

Pop out

WP

Wild pitch

/FINT

Fan interference

/INT

Interference

/BINT

Batter interference

/G+

Ground out sharply

/G-

Ground out softly

/L+

Line out sharply

/L-

Line out softly

/F+

Fly out sharply

/BG

Bunt

/P2F

Pop out to catcher in foul territory

/P3F

Pop out to first baseman in foul territory

/P5F

Pop out to third baseman in foul territory

/SAC/BG

Sacrifice bunt

/F

Fielding error, if play was an error

/TH

Error on throw

Base running.

Numbers represent base running. Don’t confuse these codes with fielding codes! These codes refer to the base number the runner is on. These codes are also always in the form “number hyphen number” (e.g., 1-3 for first base to third base). Hyphens are not used for fielding codes, only for base running codes. A semicolon separates the description of each base runner. Here is the list of these codes:

Table 1-8. 

Code

Meaning

B-1

Batter to first

B-2

Batter to second

B-3

Batter to third

B-H

Batter to home

1-2

Runner on first to second

1-3

Runner on first to third

1-H

Runner on first to home

2-3

Runner on second to third

2-H

Runner on second to home

3-H

Runner on third to home

1X1(<fielding note>)

Runner out at first

1X2(<fielding note>)

Runner out running from first to second

1X3(<fielding note>)

Runner out running from first to third

1XH(<fielding note>)

Runner out running from first to home

2X2(<fielding note>)

Runner out at second

2X3(<fielding note>)

Runner out running from second to third

2XH(<fielding note>)

Runner out running from second to home

3X3(<fielding note>)

Runner out at third

3XH(<fielding note>)

Runner out running from third to home

WP

Wild pitch; a description of base runner movement follows

PB

Passed ball; a description of base runner movement follows

Usually, the first four codes are omitted if a player ends up on the base corresponding to the type of hit (e.g., the player ends up on first base on a single). Only if the player advances beyond this base (on a throwing error, for example) are these usually listed.

Example play codes.

Here are a few examples of play codes:

K

Strikeout. Sorry, that’s the simplest one.

D7/L

Line ball double. Fielded by left fielder.

SB3;SB2

Double steal.

HR/F8

Home run to center field. (Note the “fly ball” part.)

HR7/L

Inside-the-park home run to left field. Notice that “7” is immediately after “HR”; this indicates that it is an inside-the-park home run.

S9/L

Line drive single to right field.

S9/L.2-H

Line drive single to right field. Runner scores from second base.

HR7/L.1-H;2-H;3-H

Grand slam home run to center field.

3/L

Line out to first baseman.

8/F

Fly out to center fielder.

9/SF.3-H

Sacrifice fly to right fielder. Runner on third base scores.

54(1)3/GDP

Ground into double play, third baseman to second baseman to first baseman.

54/SAC/BG.2-3;1-2

Sacrifice bunt, fielded by third baseman to second baseman. Runners on first and third advance.

13/SAC/BG.3-H

Suicide squeeze. (Sacrifice bunt ground ball, fielded by pitcher to first baseman. Runner on third scores.)

FC1/G.3XH(1); B-1

Batter reaches on a fielder’s choice. Runner on third out at home plate by pitcher, unassisted.

6/LTP.2X2(6);1X1(6)

Unassisted triple play. Line drive to shortstop.

Pitch codes.

With the Project Scoresheet system, there is also a system for recording a brief description of every pitch:

Table 1-9. 

Symbol

Meaning

.

Play not involving the batter

1

Pickoff throw to first

2

Pickoff throw to second

3

Pickoff throw to third

>

Runner going on pitch

B

Ball

C

Called strike

F

Foul

H

Batter hit by pitch

I

Intentional ball

K

Strike (unknown type: called or swinging)

L

Foul bunt

M

Missed bunt attempt

N

No pitch (balk or interference)

O

Foul tip on bunt

P

Pitchout

Q

Swinging on pitchout

R

Foul ball on pitchout

S

Swinging strike

T

Foul tip

U

Unknown (scorer missed pitch)

V

Called ball because pitcher went to his mouth

X

Ball put in play by batter

Y

Ball put in play on pitchout

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required