tournament
by Douglas A. Seifert (doug+rubyforge at dseifert dot net)
http://www.dseifert.net/code/tournament
http://tournament.rubyforge.org/
DESCRIPTION:
Small library and command line program for managing a NCAA basketball tournament pool.
FEATURES/PROBLEMS:
- Add NCAA tournament pool entries and save them as YAML
- Run a possibilities report for determining who is likely to win
- Run other reports such as a leader board and entry report
- Buggy, but functional, Shoes GUI included for creating the entries and updating the tournament results bracket.
- FIXME: Write a test suite.
SYNOPSIS:
The tournament command line program is installed as ‘pool’. The library has the 2008 NCAA tournament pre-configured. If you were to use this library for the 2009 NCAA tournament, code changes would be necessary. FIXME (add ability to read teams from a simple configuration file). For usage, just execute
pool --help
For command specific usage, execute
pool <command> --help
where <command> is one of the available commands described below. The pool command saves state in a file called pool.yml by default. This can be overridden in all cases by using the —save-file option.
The pool manager would use this program as follows:
- Choose a scoring strategy. There are various scoring strategies that could
be used. The library comes pre-configured with two scoring strategies:
- Basic scoring strategy: each correct pick is worth 2 X the round.
- Upset favoring strategy: each correct pick is worth a base amount per round plus the seed number of the winner. As pre-configured, the base amounts per round are 3, 5, 11, 19, 30 and 40 points.
If your scoring strategy is not one of the above, you will have to write a class in the Bracket class, in file lib/tournament/bracket.rb.
- Create a directory to hold the pool data and change to it
- Initialize the pool
pool setup [--scoring=upset_scoring_strategy]Use the —scoring argument to change to the upset favoring strategy. If the basic strategy is ok, the —scoring argument is not required.
As mentioned above, unless overridden by using the —save-file option, the pool will save itself to the file ‘pool.yml‘
- Set the entry fee and payout amounts
pool fee 10 pool payout 1 80 pool payout 2 20 pool payout last 10 -CThe above commands say that each entry fee is 10 units (this is all for fun, not profit, right?) and that the 1st place finisher would receive 80% of the total payout, the 2nd place finisher would receive 20% of the total payout and the last place finisher would receive 10 units back (would get her entry fee back). No error checking is done with this. FIXME: Add error checking.
- Export a tournament entry YAML file
pool dumpThis will save the tournament entry file as tournament.yml unless the —entry option is used to override it.
- Create entries. You can use the included buggy GUI (see below), or edit YAML files by hand.
- Import the entry YAML files into the pool
pool entry --add=path/to/entry.yml - As games progress, update the tournament.yml file, again using the GUI or
editing the YAML file by hand. Then update the pool with the new pool YAML
file
pool update - Run reports
pool report [final_four|entry|region|leader|score]The final four report can only be run once the final four teams have been determined.
- After about 22 teams are left, run a possibility report. This report will
run through all the remaining ways the tournament can come out and
calculate the chance to win for each player. The chance to win is defined
as the percentage of possibilities that lead to that player coming out on
top in the pool. With more than about 22 teams left (YMMV), this report
could take months to run. FIXME (Investigate possibly using EC2 or
something to spread the load around, or otherwise optimize the possibility
checking algorithm)
pool report possibility
SHOES GUI:
A GUI for filling out tournment bracket entries is included and is run by executing the program "picker". If no argument is included, a blank entry is started. It can be filled in and saved using one of the buttons at the top of the screen. The entry is saved as a YAML file for a Tournament::Entry object. The picker program optionally takes one argument, the path to a Tournament::Entry YAML file. It will open with the provided entry‘s picks pre filled in.
The GUI also may be used for keeping the NCAA tournament entry YAML file up to date:
picker tournament.yml
The GUI works as long as you don‘t try to go back and change games from played to unknown outcome.
REQUIREMENTS:
- main (2.8.0)
- shoes-0.r396 (GUI Only)
INSTALL:
- sudo gem install tournament
- Download the tgz file and run it locally. If the latter option is taken, the tournament/bin directory must be in the path.
LICENSE:
(The MIT License)
Copyright (c) 2008
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ‘Software’), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.