A framework for parsing play-by-play NBA data and using it to compute statistics
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Basketball Stats Framework by Erik Goldman

This is a library used to parse the data files from the wonderful site
basketballgeek.com.  It's poorly documented, inefficiently written, and
probably only makes sense to me, so here goes my best shot at explaining

Here are the 3 steps to computing your very own statistic!

************************** STEP ONE ********************************
Create a new java project and link in the Basketball Stats Framework jar 
file found in the bin directory of this project.

Hopefully this .jar is up-to-date, if not, it might be easier to just get the
source code instead.

If you don't know how to do this step, Google is your friend.

************************** STEP 3/2  ********************************
Go to basketballgeek.com and download the wonderful data files there.  They
will be .zip files.  Create a folder "data" in your top-level directory and
create a subfolder with the year name for that data set.

For example, download the 2008-2009 play-by-play data and unzip it to the folder

************************** STEP TWO ********************************
Create a new class that extends GameState.

Basically, everything revolves around the GameState class.  To compute a
statistic, you simply create a new class that extends GameState, and then
override one of the public methods, like:

public void shotTaken(Player p, String type, int points, boolean made)

For example, if I were trying to compute every player's shooting %, I would
store a map between each player and the number of made and missed shots. I
would then override just this method and update my count variables whenever
shotTaken is called.

************************** STEP THREE ********************************
Write a main method that invokes DataSetRunner.

This part is pretty easy, actually.  Now you just write a main method, probably
within your GameState-extended class itself, and invoke the command:

DataSetRunner.run(new MyExtensionOfGameState(MY_ARGS_GO_HERE), "2008");

If you need to pass in a Game argument to your constructor (you probably do), 
just hand it null for now.

DataSetRunner will iterate through every game in the "data/2008" folder, create
a new instance of your class (using the createCopy method), read the
play-by-play data, and call any of the callbacks that you overrode. 

When that finishes, you should (hopefully!) have the data that you're looking 

* createCopy should copy over any data structures that are shared BETWEEN
* games.  If I'm computing an NBA roster by looking at all players with > 0 minutes,
* for example, then this roster data structure needs to be shared among all 82
* games that I analyze, so it gets carried along in createCopy.  Anything
* specific to one game that doesn't need to be remembered, however, should not 
* be copied over in this method.  I hope that's clear.  If not, take a look at
* RosterCalcState.java and, if that fails, how createCopy is actually used in
* DataSetRunner.

If you get confused, take a look at the example code in PMCalc.java, which
calculates the plus-minus for every player in the league.