Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Fantasy Basketball Draft Using Minimax Chris Dietsch Department of Computer Science University of Massachusetts Lowell 1 University Ave Lowell MA 01854 [email protected] ABSTRACT In this paper we describe our findings and implementation of a fantasy basketball artificial intelligence web program designed to aid users first hand in making intelligent choices for a fantasy basketball league. In order to employ the adversarial style of a fantasy draft, we used a minimax algorithm to anticipate the choices of other players in the league. We assumed the other players to be knowledgeable and reasonable. The result of our implementation is an interactive website drawing real stats and rankings for real NBA players and accurate player photos and links to player files from [4]. Bruce Malley Department of Computer Science University of Massachusetts Lowell 1 University Ave Lowell MA 01854 [email protected] PROJECT DESCRIPTION Author Keywords Artificial Intelligence, AI, searches, adversarial search, minimax, game theory INTRODUCTION Without extensive knowledge, determining the best players to pick in a fantasy basketball draft is not an easy task. It takes knowledge of each player’s statistics, injuries, rivals, and streaks in order to create a winning team. During the fantasy draft, you typically also have a limited amount of time to make your picks. This can adversely affect your ability to choose wisely. Fortunately, using minimax, a theoretical “best team” will be created, taking all of the above information into account. From statisticians, reporters, team owners/managers, to fantasy players, a method for reliably predicting team selections in some fashion based on certain circumstances (pay grade, seniority, skill, etc) can make this solution very valuable to a multitude of people. Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. For our work, we focused on the National Basketball Association, or NBA, and its players. This allows us to limit the player selection to at most at any one given time, 450 players (30 teams, 15 roster players [12 who dress for the game] gives 450 maximum players). The work is easily extensible to the WNBA, NCAA, and any other level of play or league that has access to stats. Using minimax, making the best choices for a fantasy basketball team is a simple task. Each player in the NBA is rated based on their performance. For each player, this rating takes into account the number of games the player has played this season, the average number of minutes played, rebounds, and assists per game, field goal percentage, and free throw percentage. The rating is an overall grade of the player at a snapshot during the season. This project will use this rating to determine each player’s value to the team. The minimax algorithm will use the rating of each player to make choices. The max agent, which represents the user’s team, will attempt to maximize the user’s team rating. It will pick the best player it can to fill the five basketball positions. On the other hand, the min agents represent all of the user’s opponents. These agents will attempt to minimize your team rating, and, in turn, create the best possible team they can. The project was a joint effort between the two authors. The work was split approximately into back end and front end work. The back end includes getting outside ranking data for players into useable form and translating it into a useable format for the algorithm. Alongside this is making a relation between player photos and entries in the player files for output in the front-end. Implementing all interactive features, display capabilities, and deciding how to read the data before and after the minimax algorithm has modified it also falls into this category. The front end, including implementing the core minimax algorithm in JavaScript, is the heart of the project. The algorithm is based on an input number of teams (players) and team names. It outputs the choice of players that each player chose on their team with pictures attached to the respective athletes and links to the NBA’s player files for actual stats for that player. We built an interactive webpage (available at [2]) using these two core pieces of the project. The user is able to enter a team name for their team, choose the number of lines similar to an actual NBA team’s roster (lines are full sets of 5 players in all positions for a basketball team: center, two guards and two forwards. We split guards into their technical positions: shooting guard and point guard, and forwards into theirs: power forward and shooting forward), and how many opponents (other players in the league) to simulate. The data used pertains to the backend of the project. The rating of each player in the NBA can be found at [2]. Having downloaded the data, we then put the data into comma separated value (CSV) form. The values are ID, FirstName, LastName, position, and rating. Using CSV allowed us then to convert into JavaScript arrays, specifically JavaScript Object Notation format (JSON) based on this input CSV file. With the file in a JavaScript useable form, we also have downloaded appropriate player photos to enhance usability and aesthetics. To tie the photos with the players, we will keep the ID field in a one to one correspondence with the players of the NBA, so one number will be assigned to each player and so we can call on this number to find the picture matching this player. We went one step further during development and split the list of all players into 5 CSV (and thus, 5 JSON arrays), one file (/array) per position. So the centers were grouped up, sorted by ID, and put into a centers file, which was then converted to a centers JSON array, and similarly for the other 4 positions. The front end and the algorithm itself were mainly written in JavaScript. The web page was deployed with XHTML compliant markup and styled with CSS. This was done in order to speed up a deliverable of a final product in the required timeline. It also makes for an easy way to track user input and produce output with photos and web links, as we wanted to do. The algorithm works by iterating through nested for loops. The first for loop goes from zero to the number of players per team. The second for loop goes from zero to the number of teams in the league. This allows us to pick the ith player for the jth team. For each iteration, the code generates a random number. This random number represents a basketball position (shooting guard, point guard, power forward, shooting forward, or center). If the current team has already filled all the spots for that position, a new random number will be generated. Once a position has been decided on, the team makes its pick by adding the highest rated player that plays the position previously decided upon to the team’s array and removes that player from the player pool. This continues until all the teams are filled. ANALYSIS OF RESULTS Our project set out to give users a way to have some intelligence and planning behind a fantasy basketball draft. The resulting end product does that, and more. The project does some expectations of opponent’s picks of players beyond the trivial first few choices in a draft. It helps to explore the space of all possible choices and helps you anticipate an opponent picking a player that you would never have assumed he would have picked in that scenario. Our project is easily extensible as well, lending itself to more serious use in the future if wanted. Things like player salaries and more stats were on the cutting board for the deadline, but could easily be added into the backend and used to enhance the experience. Because all of the teams will be making the most logical and best picks, it is expected that the teams will have very similar team ratings. We expect that the teams will be very distributed amongst the top players (as any fantasy selection normally is). To make sure our selections are logical and worthy of being referred to as useful fantasy teams, we will compare with the website at [3]. This website allows you to input your fantasy team’s roster and get a valuation of that team at this moment in the season. So for our project to achieve success, it will first have picked five distinct players at five distinct positions for each team. This team will be comprised of the best choices possible at any moment in the season against a chosen number of opponents. Because of this, in the long run the chosen fantasy team (or actual team of players picked in real life draft, for the owners of teams using this, for example) will perform hopefully as well as possible. The algorithm went from general purpose team of any 5 players per line to dedicated, playable 5 player lines with 1 player required at each of the 5 unique positions. Due to this, we feel our algorithm is much more realistic and useful than it was at the onset of the project. DISCUSSION The biggest thing we learned about our project was during the implementation of minimax itself. We learned that there are key distinctions between a one level depth tree search for minimax to use, and the entire level of the tree being played out and evaluated. Our proposal and all deliverables during development led us to believe our minimax was just that, minimax searching. After examination from others and from ourselves, we learned that our experience with the algorithm and its depth of the tree maxes out at approximately one level. That is, one player pick is then followed by n min agents running, where n is the number of other players chosen by the user. The most important thing we both learned during this project’s lifespan is that this should have been not just one level deep, but instead each min agent should report a value that is the anticipation of its best possible team selection after the user chose a player, and this min agent then proceeded to simulate the remaining picks of every other computer controller player and the user’s remaining picks. Then, the top level max agent would recommend pick number two for the user to be the pick that most damages the rest of the league, that is, the pick that minimizes the expected value of all the other players in the league competing against the user. and hundreds of variables can be simulated with this minimax algorithm for a draft. An important thing about our project was that it is a good framework. It has the ability to be able to be extended upon in a natural way. This includes salaries of players for a team-wide cap, team chemistry indicators, approximations and heuristics and so on. In the sports realm numbers play a natural role in determining many things so modeling these things is not a giant leap which lends itself well to AI approaches and adjustments to our algorithm. The work done by Smyth and Balfe [5] is intriguing to our needs for this project and can be seen as an extension. Their work aims to find ways to improve future results lists of search engines based on implied preferences of a community. The community in our case is sports domain related searches, particularly basketball. What would be most useful is a way to search players based on statistics and rankings and other inputs to the minimax algorithm. These types of results, building off Smyth and Balfe’s work, can and should be ‘cached’ in a sense, in order to make more frequent updates of our back end data possible. Doing this well will lead to a more up to date and realistic view of the domain and a more useful output. A big piece of our project that we felt would be a good place to extend upon is the interactivity of the project. One player choosing against min agents who are representing intelligent enemies is useful in its own right, but the ability to play live against 1 or more human opponents gives the draft a whole new element of surprise. Probabilities are one thing in a draft based on one element (player rating) but when human players make a statistically unlikely choice of player at some moment (for team chemistry reasons, for example), the AI may perform poorly as it did not expect that choice. The implementation details of a two (or more) player setup ruled out adding this feature in favor of a more refined one player experience. The idea can be extended to an internet setting, but clearly out of time frame for this project. The idea of automating a process of predictive picking of players based on some knowledge of their worth (only estimated skill for this project, but possibly expected cost to play, team chemistry, age of player, etc) is a very valuable and lucrative idea to a great number of people. Selecting players for NBA drafts, or similar sports’ drafts is a hugely speculative process dependent on many, many variables. For example, teams decide if they need a player at a certain position based on what they currently have at that position, that player’s age and skill, the new player’s potential ability to be a difference, etc. With all these variables for just one choice, the cascading of choices over hundreds of players Other arenas will clearly be interested in this, for example websites providing fantasy sports can implement this AI and let players do mock drafts on their own in order to spend more time on their site and generate more revenue. The people using the fantasy league/website will be more inclined to use a website with more features like this and so everyone will win. CONNECTIONS TO EXISTING RESEARCH IN AI Minimax is a widely used algorithm in artificial intelligence applications for game play and adversarial searches, by definition. In preparing and implementing our minimax algorithm, we saw ways to use existing AI research not just in minimax speedups and optimizations, but in the entire process of finding data and modeling it to be useful for a sports domain application. An important part of this project was to search the web and find relevant, useful data to feed into the back end. Another problem we had to solve that has been researched is the seemingly simple problem of creating a one to one relation between players in the league and their pictures. For our timeframe, we had a brute force approach where we manually went in and assured player photos matched an immutable ID field of the CSV and eventually the JSON array. The work done by Lin, Oakes and Tait in [6] is similar to this seemingly innocuous problem. The problem of learning in the AI sense which pictures match which players is not a simple one. With new players changing team (and therefore new photos) and rookies entering and veterans retiring, the database could become stale rather quickly. Finding a way to learn which player belongs to which field in the database automatically as opposed to manually is another large advantage to the overall effectiveness of the project. An interesting piece of research that is highly related to our project’s results and hypothesis is presented in Hurley [7]. Our hypothesis revolves around the idea of a ‘momentum’ in a large sense—the momentum of a player’s career and their season affects their value to the user and to the min agents acting as users. This research says that without this model of momentum and a statistical background (i.e. their propensity to continue to play well if they won an MVP award last season), the problem of choosing players could be just as simple as choosing names at random to fill your team. In modeling players in a more sophisticated way, where their rating is not just a number but an indicator of their playing during the season and previous seasons to an extent (the numbers gathered from [1] are just this), we have a much more in depth problem where minimax is a more suitable choice of attack to the problem of anticipating performance over a longer period of time (a season). CONCLUSIONS The resulting deliverable of our project satisfies what we set out to achieve: a working, real-time interactive webpage complete with working player links and photos for each player that uses a minimax algorithm to anticipate player choices for the opponents in the league and generates expected and recommended choices for the user. An auto pick option is also included to give a user an idea of what to reasonably expect on their team given n players in the league, assuming intelligent opponents. The most logical additions to this project have been stated: player salaries as arguments to the minimax routine, along with other heuristic and complicating factors in order to more closely mimic reality, multiple user capabilities, team chemistries, and so on. ACKNOWLEDGMENTS As a team of two, the work was divided approximately equally, or more specifically, into the two domains of front end and back end. Chris was responsible for the player picture downloads and the construction of the relation between photos and player in the CSV and JSON. Alongside this was the work of gathering player data from [1] and modifying it to suit our needs. Chris also styled the webpage with CSS. Bruce was responsible for architecting the minimax solution in JavaScript, the heart of the project itself. As he dealt with the outputs of his algorithm he was also responsible for XHTML development to allow user input and readable output. The work described in this paper was conducted as part of a Fall 2010 Artificial Intelligence course, taught in the Computer Science Department of the University of Massachusetts Lowell by Prof. Fred Martin. REFERENCES 1. CBS Sports player rankings. http://www.cbssports.com/nba/playerrankings/regularse ason/OVERALL 2. Interactive Final Project. http://weblab.cs.uml.edu/~bmalley/ai/ 3. Fantasy team analyzer. http://www.fantasysp.com/team_analyzer/nba/ 4. National Basketball Association. http://www.nba.com 5. Barry Smyth and Evelyn Balfe. 2006. Anonymous personalization in collaborative web search. Inf. Retr. 9, 2 (March 2006), 165-190. DOI=10.1007/s10791-0067148-z http://dx.doi.org/10.1007/s10791-006-7148-z 6. Wei-Chao Lin, Michael Oakes, and John Tait. 2010. Improving image annotation via representative feature vector selection. Neurocomput. 73, 10-12 (June 2010), 1774-1782. DOI=10.1016/j.neucom.2010.01.019 http://dx.doi.org/10.1016/j.neucom.2010.01.019 7. W. J. Hurley. 2002. How Should Team Captains Order Golfers on the Final Day of the Ryder Cup Matches? Interfaces 32, 2 (March 2002), 74-77. DOI=10.1287/inte.32.2.74.64 http://dx.doi.org/10.1287/inte.32.2.74.64