private void solve(Team t) {
    if (eliminators.containsKey(t.name)) {
      return;
    } // result is cached, so don't recalculate it

    // Trivial elimination
    if (!t.equals(teams[leader]) && isTriviallyEliminated(t)) {
      eliminators.put(
          t.name,
          new SET<String>() {
            {
              add(teams[leader].name);
            }
          }); // I bet checkstyle HATES this. //TODO: I bet this is a bug where sliminators are
              // overwritten
      return;
    }

    // Maxflowy realzo elimination
    FordFulkerson ffFlow = graphTheTeam(t);
    if (isNumericallyEliminated(t, ffFlow.value())) {
      for (int i = 0; i < numberOfTeams(); i++) {
        if (ffFlow.inCut(i)) {
          SET<String> winners = new SET<String>();
          if (eliminators.containsKey(t.name)) {
            winners = eliminators.get(t.name);
          }
          winners.add(teams[i].name);
          eliminators.put(t.name, winners);
        }
      }
    }
  }
Esempio n. 2
0
 public ArrayList<Cell> seenCells(Team team) {
   ArrayList<Cell> c = new ArrayList<Cell>();
   if (team.equals(Team.team1)) {
     c.addAll(sightTower1);
     c.addAll(sightHero(team1));
   } else {
     c.addAll(sightTower2);
     c.addAll(sightHero(team2));
   }
   return c;
 }
  private void updatePointsSelector(Tossup t) {
    Team winner = t.getWinnerTeam();
    RadioGroup winnerGroup;
    RadioGroup loserGroup;

    if (winner.equals(game.getTeamA())) {
      winnerGroup = (RadioGroup) findViewById(R.id.teamaradiogroup);
      loserGroup = (RadioGroup) findViewById(R.id.teambradiogroup);
    } else {
      winnerGroup = (RadioGroup) findViewById(R.id.teambradiogroup);
      loserGroup = (RadioGroup) findViewById(R.id.teamaradiogroup);
    }
    this.modifyingRadioButtons = true;
    switch (t.getWinnerPoints()) {
      case 15:
        ((RadioButton) winnerGroup.getChildAt(0)).setChecked(true);
        enableBonusBoxes();
        break;
      case 10:
        ((RadioButton) winnerGroup.getChildAt(1)).setChecked(true);
        enableBonusBoxes();
        break;
      case 0:
        ((RadioButton) winnerGroup.getChildAt(2)).setChecked(true);
        disableBonusBoxes();
        break;
      case -5:
        throw new RuntimeException("Winner can't have -5");
      default:
        throw new RuntimeException("Invalid point value for winner");
    }

    switch (t.getLoserPoints()) {
      case 0:
        ((RadioButton) loserGroup.getChildAt(2)).setChecked(true);
        break;
      case -5:
        ((RadioButton) loserGroup.getChildAt(3)).setChecked(true);
        break;
      default:
        // this should never happen
        ((RadioButton) loserGroup.getChildAt(2)).setChecked(true);
        break;
    }
    this.modifyingRadioButtons = false;
  }