Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/lineup/LineUp.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ public double getPts() {
}
return pts;
}

public void updatePlayerDemographics() {
for(Player p : _getPlayers()) p.incrementMembership();
}

private ArrayList<Player> _getPlayers() {
return players;
Expand Down
41 changes: 32 additions & 9 deletions src/main/FindOptimalLineups.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class FindOptimalLineups {
private static final int minProj = 2;
// tweak this number to change the number of combinations that are tried.
private static final int cutOffNum = 5;
private static final int topLineUpsDemographics = 20;

// CLASS SPECIFIC THINGS
private static ArrayList<Player> qbs;
Expand Down Expand Up @@ -89,21 +90,16 @@ public static void main (String[] args) throws FileNotFoundException {
// The core of everything. The recursive call to generate the lineups.
// TODO make this not recursive to save the stack.
generateLineUps(1, new LineUp(budget), maxCosts);




System.out.println("DONE");
System.out.println(lineUps.size());
System.out.println("Total Lineups Generated: " + lineUps.size());
Collections.sort(lineUps);
for (int i = 0; i < 50; i++) {
System.out.println("index " + (i * 100) + ": " + lineUps.get(i*100));
}
System.out.println("PLAYERS IN COMBINATIONS");
System.out.println(qbs);
System.out.println(rbs);
System.out.println(wrs);
System.out.println(tes);
System.out.println(dsts);
outputPositions(qbs, rbs, wrs, tes, dsts);

int medianValue = 163;

Expand All @@ -112,6 +108,33 @@ public static void main (String[] args) throws FileNotFoundException {
printWinningPercentage(2000, medianValue);
printWinningPercentage(200, medianValue);
printWinningPercentage(20, medianValue);

updateDemographics(FindOptimalLineups.topLineUpsDemographics);
}

public static void outputPositions(ArrayList<Player>... args) {
for (ArrayList<Player> position : args) System.out.println(position);
}

public static void printDemographics(int totalTeams) {
System.out.println("\nDemographic Data for top " + totalTeams + " lineups");
System.out.println("-----------------");
for (int i=0; i<playerMatrix.size(); i++) {
if (i!=1)
for (Player p : playerMatrix.get(i)) {
double percentage = ((double) p.getMembership()*100) / totalTeams;
System.out.printf(p.getName()+": " + "%1.2f" + "%%\n", percentage);
}
}
}

public static void updateDemographics(int numPlayers) {
for (int i = 1; i <=numPlayers*100; i++) {
lineUps.get(i).updatePlayerDemographics();
if (i==numPlayers) printDemographics(i);
if (i==(numPlayers*10)) printDemographics(i);
}
printDemographics(numPlayers*100);
}

public static void printWinningPercentage(int freq, int threshold) {
Expand Down Expand Up @@ -238,7 +261,7 @@ public static void generateLineUps(int depth, LineUp curLineUp, int[] maxCosts)
if (depth == 10) {
if (lineUps.size() % 10000 == 0) {
//System.out.println(lineUps.size());
}
}
lineUps.add(curLineUp);
return;
}
Expand Down
10 changes: 10 additions & 0 deletions src/playertypes/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public abstract class Player implements Comparable<Player> {
protected String name;
protected int cost;
protected double pts;
protected int membership;

public abstract double getProjection();
//public abstract double getFantasyPts();
Expand All @@ -17,6 +18,15 @@ public abstract class Player implements Comparable<Player> {
public Player(String name) {
this.name = name;
pts = .001;
membership = 0;
}

public int getMembership() {
return this.membership;
}

public void incrementMembership(){
this.membership++;
}

public String getName() {
Expand Down
2 changes: 1 addition & 1 deletion src/playertypes/QB.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@ public void loadProjections(String data) {
this.projRushTds = Double.parseDouble(d[9]);
this.projFumbles = Double.parseDouble(d[10]);
}
}
}