Coder Social home page Coder Social logo

fantasy-knapsack's Introduction

Fantasy football auction knapsack solver

Simple tool to keep track of the fantasy auction draft. It is initialized with csv files containing projections for each individual position (the data can be obtained from fftoday.com, for example).

Sample format of the cvs file for each position:

  • QB: Name, Team, Bye week, attempts, completions, yards, TDs, INTs, rushing attempts, rushing yards, rushing TDs, season fantasy points
  • RB: Name, Team, Bye week, rushing attempts, yards, TDs, receptions, yards, TDs, season points
  • WR: Name, Team, Bye week, receptions, yards, TDs, rushes, yards, TDs, season points
  • TE: Name, Team, Bye week, receptions, yards, TDs, season points

Of these fields only Name, Team, and season points are used. These uniquely identify each player to allow figuring out which ones are on the team.

For each position, a points to cost is defined (I couldn't find a better way to assign cost to each player).

From that, 0-1 knapsack algorithm is used to figure out the best team combination within a $200 budget. The algorithm takes into account the team and prevents more than a set number of players to be on a team (e.g. only one QB).

The algorithm does not attempt to ensure a certain number of players on a team (for example, it may product out a team of 5).

How to use

Create files qbs.csv, rbs.csv, wrs.csv, and tes.csv. Run the program with python ./fantasy_knapsack.py. To get help, type in help.

You can remove players from the pool with rm <player name>. Add a player to your team with add <player name> <cost>. The cost will be deducted from your budget.

budget will show the current budget.

team will show the current team.

best_team will run the knapsack algorithm and print out the current best team.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.