Fantasy basketball (hoops) is one of many fantasy sports games played on the Internet. In these games, each participant selects a certain number of professional players, to make up her ``team.'' (In real life, these players usually do not play for the same team; that's where the ``fantasy'' comes in.) After each game, each player's performance is assessed as a function of the player's game statistics. A participant in the fantasy-hoops game wins if the players on her team, collectively, perform better in their professional games than the players selected by other participants. Examples of specific fantasy leagues can be found at The Sporting News.
For purposes of this assignment, we'll measure an NBA player's performance as the number of points that he scores, plus 1.5 times the number of rebounds he makes, plus twice the number of assists he makes. For example, on November 28, 2001, Allen Iverson scored forty points and had six rebounds and three assists. So his performance for that game would be scored as 40 + 1.5 * 6 + 2 * 3, or 55.
The purpose of this assignment is to write a Scheme program that selects a fantasy-hoops team from a given pool of players. The file /home/gum/public_html/courses/151/exercises/players.txt contains information about each of the nineteen players in the pool: the player's name, his current averages (points per game, rebounds per game, and assists per game), and his annual salary (in millions of dollars). (We made up this last statistic and do not guarantee its real-world accuracy.)
Your objective is to use these statistics to select the best possible team of five players, using each player's past performance (as reflected in his averages) as an estimate of his future performance. As in actual NBA basketball, there is a salary cap: The total of the salaries of the five players you choose may not exceed $25,000,000. This means that you can't simply compute a performance score for each player and take the five highest; you'll find that that salaries of those five players add up to more than $25,000,000.
Observing this restriction, a program might (for instance) recommend the team of Predrag Stojakovic, Dirk Nowitzki, Jerry Stackhouse, Baron Davis, and Michael Finley. The total of those players' performance scores is 191.2, and their salaries add up to only $21,770,000, which is safely less than the salary cap. Perhaps, however, you can do better by selecting a different combination of players. There are about seven thousand possible teams; ideally, your program will find the best one.
Your program should read in information from the players file and use it to
create an record for each player, with name, points, rebounds, assists, and salary. In addition to the usual
procedures for the record type, you should create an average-fantasy-score procedure, which takes a player as its argument and
returns his average performance score, using the formula presented above.
Then use this procedure to define a procedure best-team that takes
three arguments, team-size (in this case 5), salary-cap (in
this case 25), and players (a list of all the player records), and
returns a list containing three items: a list of the players on your team,
the total of their salaries (in millions of dollars), and the total of
their average performance scores.
This document is available on the World Wide Web as
http://www.cs.grinnell.edu/~stone/courses/scheme/exercises/fantasy-hoops.xhtml
created November 29, 2001
last revised November 30, 2001
Ben Gum (gum@cs.grinnell.edu) and John David Stone (stone@cs.grinnell.edu)