Ejemplo n.º 1
0
  public void calcGrades() {

    for (Team t : season.getTeams()) {
      double grade;
      //			if t.grt
      //			grade = t.getDrawPercentage()*drawPercentagePercent +
      // t.getNoDrawStreak()*noDrawStreakPercent + t.getMaxNoDrawStreak()*maxNoDrawStreakPercent;
      grade =
          t.getDrawPercentage() * drawPercentagePercent
              + ((t.getMaxNoDrawStreak() != 0) ? t.getNoDrawStreak() / t.getMaxNoDrawStreak() : 0)
                  * noDrawStreakPercent;

      /*double nextGamesGrade = 0;
      //System.out.println("Next games: " + t.getNextGames(streakLength).size());
      for(Game g : t.getNextGames(streakLength)) {
      	//nextGamesGrade += (double) (season.getTeams().size() - Math.abs(t.getRank() - g.getOpponent(t).getRank())) / season.getTeams().size();
      	nextGamesGrade += (double) g.getOpponent(t).getDrawPercentage();
      	//if(g.getOpponent(t).getDrawPercentage() >= 0.25) {
      		//nextGamesGrade += 0.1;
      	//}

      }*/
      Map<String, Double> nextMap = t.getNextGamesStats(streakLength);
      grade += /*nextGamesGrade / streakLength*/
          nextMap.get("drawPercentage") * nextGamesGradePercent;
      grade += (Double) nextMap.get("poss") * oppPosPercent;
      grade += t.getAVGPoss() * posPercent;
      grade += nextMap.get("scoreRatio") * oppScoreRatioPercent;
      grade += t.getScoreRatio() * scoreRatioPercent;
      grade += t.getCornerRatio() * cornerRatioPercent + nextMap.get("cornersRatio");
      t.setGrade(grade);
      /*if(t.getDrawPercentage() >= minDrawPercentage && t.getMaxNoDrawStreak()-t.getNoDrawStreak() <= streakLength) {
      	ArrayList<Game> nextGames = t.getNextGames(streakLength);
      	double sumDrawPercentage = 0;
      	for(Game g : nextGames) {
      		if(g.getOpponent(t) != null) sumDrawPercentage+= g.getOpponent(t).getDrawPercentage();
      	}
      	if(sumDrawPercentage/streakLength >= 0.25) {
      		runningTeam = t;
      		//this.setRunning(true);
      		break;
      	}
      }*/
    }
  }
Ejemplo n.º 2
0
  public void pickTeam() {
    ArrayList<Team> teams =
        season
            .getTeams(); // new ArrayList<Team>(season.getTeams()); //copy teams into new arraylist
    Collections.sort(
        teams,
        new Comparator<Team>() {

          @Override // sort teams by draw percentage
          public int compare(Team o1, Team o2) {
            return Double.compare(o2.getGrade(), o1.getGrade());
          }
        });
    for (Team t : teams) {
      // System.out.println();
      if (t.getGrade() >= gradeMinLimit
          && !runningTeams.contains(t)
          && calcActiveStreaks() < maxStreaks) {
        runningTeams.add(t);
        generateStreaks();
      }
    }
    if (runningTeams.size() > 0) this.setRunning(true);
  }